Update change log and spec for wrt-plugins-tizen_0.4.14
authorDongjin Choi <milkelf.choi@samsung.com>
Fri, 5 Apr 2013 13:25:43 +0000 (22:25 +0900)
committerDongjin Choi <milkelf.choi@samsung.com>
Fri, 5 Apr 2013 13:25:43 +0000 (22:25 +0900)
[model] REDWOOD
[binary_type] PDA
[customer] OPEN

[Issue#] N/A
[Problem] N/A
[Cause] Common] Add MultiCallbackUserDataPtr using boost::shared_ptr
[Solution] N/A

[Issue#] CID-49206
[Problem] Copy-paste error for DataSyncManager.
[Cause] Copy-paste error.
[Solution] Fix wrong paste statement.

[Issue#] CID-48299/CID-48300/CID-48301
[Problem] JSSetArrayElement return value is not checked
[Cause] JSSetArrayElement return value is not checked
[Solution] check the return value

[Issue#] prevent issue CID 49538.
[Problem] uninitialized variable usage.
[Cause] assignment omission in else block.
[Solution] modification.

[Issue#] CID 48472
[Problem] Passing null pointer "priv" to function.
[Cause] N/A
[Solution] Fix a bug

[Issue#] N/A
[Problem] CID 49049
[Cause]  No reached code exist
[Solution] It was removed.

[Issue#] CID-49473, CID-49474, CID-49475, CID-49192, CID-49193
[Problem] leaked storage and unchecked return value
[Solution] checked return value and destroyed leaked handle.
[SCMRequest] N/A

[Issue#] N_SE-31232
[Problem] the geolocation data is different with private object
[Cause] N/A
[Solution] set/get property is control by parent object

[Issue#] N/A
[Problem] N/A
[Cause]     [Common] Add PropertyBag module [ReferenceImplement] How to implement readonly property, How to pass property equality check
[Solution] N/A

[Issue#] N/A
[Problem] Calendar geolocation value not changed when setting it by property setter.
[Cause] Private value not managed by setter.
[Solution] Use Tizen SimpleCoordinates private value instead of internal values.

[Issue#] DCM-1193
[Problem] All calendar events were returned when using date range filter.
[Cause] No calendar id filter set for recurring event range filter.
[Solution] Add calendar id filter for recurring event range filter.

[Issue#] N/A
[Problem] some tc is failed because of timing issue
[Cause] N/A
[Solution] delete kill code

[Issue#] TDIS-3933 TDIS-4146
[Problem] Types of filters and values are not valid
[Cause] Filter object did not handle with JSValueRef
[Solution] Handle with JSValueRef

[Issue#] TDIS-4478
[Problem] Exception name is incorrect.
[Cause] Internal bug.
[Solution] Modification.

[Issue#] N/A
[Problem] Exception name is incorrect.
[Cause] Internal bug.
[Solution] Modification.

[Issue#] N/A
[Problem] some tc is failed by timing issue
[Cause] N/A
[Solution] update tc to avoid timing issue

[Issue#] N/A
[Problem] msg-service DB release
[Cause] msg-service DB release
[Solution] msg-service DB release

[Issue#] N/A
[Problem] error callback is occured when releaseDate set through filter
[Cause] N/A
[Solution] chagne the filter map

[Issue#] N/A
[Problem] Out-dated JS attribute getter/setter policy.
[Cause] New policy introduced.
[Solution] Change flags for readonly attributes and return true for setter type mismtach exceptions.

[Issue#] DCM-1241
[Problem] "Find" api even finds the deleted items when some accounts are synchronized.
[Cause] "Find" api didn't set the "is_deleted" filter flag to false.
[Solution] Set the "is_deleted" flag to false in find api filter imlementation.

[Issue#] N/A
[Problem] getEventFromHandle event error handling bug fix
[Cause] getEventFromHandle event error handling bug fix
[Solution] getEventFromHandle event error handling bug fix

[Issue#] N/A
[Problem] N/A
[Cause] [Common] Add Time Tracer for profiling
[Solution] N/A

[Issue#] N/A
[Problem] N/A
[Cause] [Push] Refactoring for DPL-Free version
[Solution] N/A

[Issue#] N/A
[Problem] N/A
[Cause] bookmark framework's root folder id is changed.
[Solution] The definition of root folder id is removed and codes related to it are changed.

[Issue#] N/A
[Problem] types concept is not clear
[Cause] document error
[Solution] update document and modify code

[Issue#] N/A
[Problem] object is not deleted after use
[Cause] N/A
[Solution] remove resource afte use

[Issue#] DCM-714
[Problem] Crash is occured when multiple html pages open.
[Cause] JSValueRef is freed.
[Solution] Modification.

[Issue#] N/A
[Problem] Occured crash if matchValue of AttributeFilter not set
[Cause] There is problem on FilterConverter
[Solution] FilterConverter checks converted result carefully

[Issue#] N/A
[Problem] new guide
[Cause] new guide
[Solution] modify code

[Issue#] N/A
[Problem] typo error of pc file
[Cause] N/A
[Solution] Fixed type error

[Issue#] N/A
[Problem] Message port's privilege did not work
[Cause] privilege resist code did not enable
[Solution] Enabled privilege code

[Issue#] N/A
[Problem] new guide
[Cause] new guide
[Solution] modify code

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

169 files changed:
packaging/wrt-plugins-tizen.spec
pkgconfigs/wrt-plugins-tizen-callhistory.pc.in [changed mode: 0644->0755]
pkgconfigs/wrt-plugins-tizen-contact.pc.in [changed mode: 0644->0755]
pkgconfigs/wrt-plugins-tizen-filesystem.pc.in [changed mode: 0644->0755]
src/Alarm/CMakeLists.txt
src/Application/CMakeLists.txt
src/Bookmark/BookmarkData.h
src/Bookmark/BookmarkManager.cpp
src/Bookmark/JSBookmarkFolder.cpp
src/Bookmark/JSBookmarkManager.cpp
src/CMakeLists.txt
src/Calendar/CMakeLists.txt
src/Calendar/Calendar.cpp
src/Calendar/CalendarConverter.cpp
src/Calendar/CalendarEvent.cpp
src/Calendar/CalendarEvent.h
src/Calendar/CalendarFilter.cpp
src/Calendar/CalendarFilter.h
src/Calendar/CalendarFilterConverter.cpp [new file with mode: 0644]
src/Calendar/CalendarFilterConverter.h [new file with mode: 0644]
src/Calendar/CalendarFilterValidator.cpp
src/Calendar/EventRecurrenceRule.cpp
src/Calendar/EventWrapper.cpp
src/Calendar/JSCalendar.cpp
src/Calendar/JSCalendarAlarm.cpp
src/Calendar/JSCalendarAttendee.cpp
src/Calendar/JSCalendarEvent.cpp
src/Calendar/JSCalendarEventId.cpp
src/Calendar/JSCalendarItemProperties.cpp
src/Calendar/JSCalendarManager.cpp
src/Calendar/JSCalendarRecurrenceRule.cpp
src/Calendar/JSCalendarTask.cpp
src/Callhistory/CMakeLists.txt
src/Callhistory/CallHistory.cpp
src/Callhistory/CallHistoryFilter.cpp
src/Callhistory/CallHistoryFilterConverter.cpp [new file with mode: 0644]
src/Callhistory/CallHistoryFilterConverter.h [new file with mode: 0644]
src/Callhistory/JSCallHistory.cpp
src/Common/CMakeLists.txt [changed mode: 0644->0755]
src/Common/MultiCallbackUserData.cpp
src/Common/MultiCallbackUserData.h
src/Common/PropertyBag.cpp [new file with mode: 0755]
src/Common/PropertyBag.h [new file with mode: 0755]
src/Common/TimeTracer/CMakeLists.txt [new file with mode: 0644]
src/Common/TimeTracer/TimeTracer.c [new file with mode: 0644]
src/Common/TimeTracer/TimeTracer.h [new file with mode: 0644]
src/Contact/CMakeLists.txt
src/Contact/ContactConverter.cpp
src/Contact/ContactFilterConverter.cpp [new file with mode: 0644]
src/Contact/ContactFilterConverter.h [new file with mode: 0644]
src/Contact/ContactSearchEngine.cpp
src/Contact/JSAddressBook.cpp
src/Contact/JSContact.cpp
src/Contact/JSContactAddress.cpp
src/Contact/JSContactAnniversary.cpp
src/Contact/JSContactEmailAddress.cpp
src/Contact/JSContactGroup.cpp
src/Contact/JSContactManager.cpp
src/Contact/JSContactName.cpp
src/Contact/JSContactOrganization.cpp
src/Contact/JSContactPhoneNumber.cpp
src/Contact/JSContactWebSite.cpp
src/Contact/JSPerson.cpp
src/Contact/PersonFilterValidator.cpp
src/Content/CMakeLists.txt
src/Content/ContentConverter.cpp
src/Content/ContentFilterConverter.cpp [new file with mode: 0755]
src/Content/ContentFilterConverter.h [new file with mode: 0644]
src/Content/ContentFilterValidator.cpp
src/Content/ContentSearchVisitor.cpp
src/Content/JSContentManager.cpp
src/DataControl/CMakeLists.txt
src/DataSync/CMakeLists.txt
src/DataSync/JSSyncInfo.cpp
src/DataSync/JSSyncProfileInfo.cpp
src/DataSync/JSSyncServiceInfo.cpp
src/DataSync/JSSyncStatistics.cpp
src/Download/CMakeLists.txt
src/Download/DownloadCallback.cpp
src/Download/DownloadManager.cpp
src/Download/JSDownloadRequest.cpp
src/Filesystem/CMakeLists.txt
src/Filesystem/ResponseDispatcher.cpp
src/MessagePort/JSMessagePortManager.cpp
src/MessagePort/plugin_config.cpp
src/Messaging/CMakeLists.txt
src/Messaging/ConversationFilterValidatorFactory.cpp
src/Messaging/ConversationQueryGenerator.cpp
src/Messaging/FolderFilterValidator.cpp
src/Messaging/FolderQueryGenerator.cpp
src/Messaging/FolderQueryGenerator.h
src/Messaging/JSMessage.cpp
src/Messaging/JSMessageBody.cpp
src/Messaging/JSMessagingStorage.cpp
src/Messaging/JSRecipientArray.cpp
src/Messaging/MailSender.cpp
src/Messaging/MailSync.cpp
src/Messaging/MessageFilterConverter.cpp [new file with mode: 0644]
src/Messaging/MessageFilterConverter.h [new file with mode: 0644]
src/Messaging/MessageFilterValidator.cpp
src/Messaging/MessageQueryGenerator.cpp
src/Messaging/Messaging.cpp
src/Messaging/StorageChangesConversationFilterValidator.cpp
src/Messaging/StorageChangesConversationFilterValidatorFactory.cpp
src/Messaging/StorageChangesConversationGenerator.cpp
src/Messaging/StorageChangesFolderFilterValidator.cpp
src/Messaging/StorageChangesFolderFilterValidatorFactory.cpp
src/Messaging/StorageChangesMessageFilterValidator.cpp
src/Messaging/StorageChangesMessageFilterValidatorFactory.cpp
src/Messaging/StorageChangesMessageGenerator.cpp
src/Messaging/messageDB/MessageStorageReader.cpp
src/Messaging/messageDB/MessageStorageReader.h
src/Messaging/messageDB/MessageStorageReaderData.h [new file with mode: 0644]
src/Notification/CMakeLists.txt
src/Package/CMakeLists.txt
src/Package/JSPackageManager.cpp [changed mode: 0755->0644]
src/Package/PackageManager.cpp [changed mode: 0755->0644]
src/Power/CMakeLists.txt
src/Power/PowerManager.cpp
src/Push/CMakeLists.txt [changed mode: 0755->0644]
src/Push/IEventConnectService.h [deleted file]
src/Push/IEventDisconnectService.h [deleted file]
src/Push/IEventGetRegistrationId.h [deleted file]
src/Push/IEventRegisterService.h [deleted file]
src/Push/IEventUnregisterService.h [deleted file]
src/Push/IPushManager.cpp [deleted file]
src/Push/IPushManager.h [deleted file]
src/Push/JSPushManager.cpp
src/Push/JSPushManager.h [changed mode: 0755->0644]
src/Push/JSPushMessage.cpp
src/Push/JSPushMessage.h [changed mode: 0755->0644]
src/Push/OnPushNotified.h [deleted file]
src/Push/PushAsyncCallbackManager.cpp [deleted file]
src/Push/PushAsyncCallbackManager.h [deleted file]
src/Push/PushConverter.cpp [deleted file]
src/Push/PushConverter.h [deleted file]
src/Push/PushListenerManager.cpp [deleted file]
src/Push/PushListenerManager.h [deleted file]
src/Push/PushManager.cpp
src/Push/PushManager.h [changed mode: 0755->0644]
src/Push/PushMessage.cpp [changed mode: 0755->0644]
src/Push/PushMessage.h [changed mode: 0755->0644]
src/Push/PushResponseDispatcher.cpp [deleted file]
src/Push/PushResponseDispatcher.h [deleted file]
src/Push/PushTypes.h [new file with mode: 0644]
src/Push/plugin_config.cpp [changed mode: 0755->0644]
src/Push/plugin_config.h [changed mode: 0755->0644]
src/Push/plugin_initializer.cpp
src/SystemSetting/CMakeLists.txt
src/SystemSetting/JSSystemSetting.cpp
src/Systeminfo/EventWatchSysteminfo.cpp
src/Systeminfo/SysteminfoFactory.cpp
src/Tizen/AnyFactory.cpp [new file with mode: 0644]
src/Tizen/AnyFactory.h [new file with mode: 0644]
src/Tizen/AnyType.cpp
src/Tizen/AnyType.h
src/Tizen/CMakeLists.txt
src/Tizen/FilterConverter.cpp
src/Tizen/FilterConverter.h
src/Tizen/FilterValidator.cpp
src/Tizen/FilterValidator.h
src/Tizen/IFilterProperties.cpp [new file with mode: 0644]
src/Tizen/IFilterProperties.h [new file with mode: 0644]
src/Tizen/JSAttributeFilter.cpp
src/Tizen/JSAttributeFilter.h
src/Tizen/JSAttributeRangeFilter.cpp
src/Tizen/JSAttributeRangeFilter.h
src/Tizen/JSCompositeFilter.cpp
src/Tizen/JSCompositeFilter.h

index f1eafc3..73485ba 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       wrt-plugins-tizen
 Summary:    JavaScript plugins for WebRuntime
-Version:    0.4.13
+Version:    0.4.14
 Release:    0
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
old mode 100644 (file)
new mode 100755 (executable)
index 3a512ba..4c18371
@@ -1,6 +1,6 @@
 prefix=/usr
 project_name=@CMAKE_PROJECT_NAME@
-module_name=callhistroy
+module_name=callhistory
 exec_prefix=${prefix}
 libdir=${prefix}/lib/wrt-plugins/tizen-${module_name}
 includedir=${prefix}/include/${project_name}
old mode 100644 (file)
new mode 100755 (executable)
index b9f163f..c54a2f3
@@ -8,6 +8,6 @@ includedir=${prefix}/include/${project_name}
 Name: wrt-plugins-tizen-${module_name}
 Description: wrt-plugins-tizen-${module_name}
 Version: @CMAKE_PROJECT_VERSION@
-Requires: contacts-service2 libpcrecpp capi-web-url-download
+Requires: contacts-service2 libpcrecpp
 Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config
 Cflags: -I${includedir}/${module_name}
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index c9c5995..3deb9e4
@@ -1,6 +1,6 @@
 prefix=/usr
 project_name=@CMAKE_PROJECT_NAME@
-module_name=log
+module_name=filesystem
 exec_prefix=${prefix}
 libdir=${prefix}/lib/wrt-plugins/tizen-${module_name}
 includedir=${prefix}/include/${project_name}
index fd30c2e..c01b0b0 100755 (executable)
@@ -33,8 +33,9 @@ ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL})
 TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME}
        ${LIBS_COMMON}
        ${platform_pkgs_alarm_LIBRARIES}
-       ${application_impl}
        ${tizen_impl}
+       ${application_impl}
+       ${timeutil_impl}
 )
 
 SET(SRCS
index 1a46ce2..d24a3b1 100755 (executable)
@@ -20,7 +20,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
 )
 
index 29d214e..2f98dfa 100755 (executable)
@@ -22,8 +22,7 @@
 namespace DeviceAPI {
 namespace Bookmark {
 
-#define UNDEFINED_ID 0
-#define ROOTFOLDER_ID 1
+#define UNDEFINED_ID -1
 
 enum bookmarkType {
        BOOKMARKITEM_TYPE = 0,
index 326b33e..a331bfe 100755 (executable)
@@ -253,7 +253,7 @@ BookmarkManager* BookmarkManager::getInstance(){
 }
 
 BookmarkManager::BookmarkManager(){
-       rootFolderId = 1;
+       rootFolderId = 0;
        favorites_bookmark_get_root_folder_id(&rootFolderId);
 }
 BookmarkManager::~BookmarkManager(){
index 50aad17..94312b5 100755 (executable)
@@ -143,7 +143,7 @@ JSValueRef JSBookmarkFolder::getParent(JSContextRef context, JSObjectRef object)
                BookmarkParentSearchDataPtr parentSearchData(new BookmarkParentSearchData(priv->m_id, priv->m_parentId));
                bool isAlive = BookmarkManager::getInstance()->findParent(parentSearchData);
                if (isAlive) {
-                       if (priv->m_parentId == ROOTFOLDER_ID)
+                       if (priv->m_parentId == BookmarkManager::getInstance()->getRootFolderId())
                                return JSValueMakeNull(context);
                        else
                                return createJSObject(context, (parentSearchData->m_parent)->m_title, (parentSearchData->m_parent)->m_id, (parentSearchData->m_parent)->m_parentId);
index 83bf3df..3edc2ce 100755 (executable)
@@ -144,9 +144,6 @@ JSValueRef JSBookmarkManager::get(JSContextRef ctx, JSObjectRef object, JSObject
     }catch( const BasePlatformException& err){
         return JSWebAPIError::throwException(ctx, exception, err);
     }
-
-    return JSValueMakeUndefined(ctx);
-
 }
 
 JSValueRef JSBookmarkManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
@@ -181,7 +178,7 @@ JSValueRef JSBookmarkManager::add(JSContextRef ctx, JSObjectRef object, JSObject
                                throw TypeMismatchException("Parent Folder private data is null");
                }
 
-               int parentId = 0;
+               int parentId = UNDEFINED_ID;
                if (parentFolder)
                        parentId = parentFolder->m_id;
                else
index c310af9..a74a457 100755 (executable)
@@ -18,10 +18,12 @@ set(LIBS_COMMON
 )
 
 add_subdir(Common/StandaloneConsole)
+add_subdir(Common/TimeTracer)
 
 set(LIBS_TEST
   ${LIBS_COMMON}
   "standaloneconsole"
+  "timetracer"
 )
 
 # -----------------------------------------------------------------------------
@@ -29,8 +31,8 @@ set(LIBS_TEST
 # -----------------------------------------------------------------------------
 
 add_plugin(
-       TimeUtil
        Tizen
+       TimeUtil
        Content
        Calendar
        Contact
index ac9b70c..9084841 100755 (executable)
@@ -23,6 +23,7 @@ SET(CMAKE_INSTALL_RPATH
 SET(SRCS_IMPL
        CalendarResponseDispatcher.cpp
        CalendarConverter.cpp
+       CalendarFilterConverter.cpp
        JSCalendarEvent.cpp
        JSCalendarTask.cpp
        JSCalendarItemProperties.cpp
index f10593f..050e02e 100755 (executable)
@@ -722,11 +722,12 @@ void Calendar::OnRequestReceived(const IEventFindEventsPtr &event)
                 LogDebug("Filter validation has passed.");
             }
 
+                       calendarFilter->setCalendarIdForEvent(calendarId);
                        genericFilter->travel(filterTraversal, 0);
 
                        if(getIsUnified()) {
                                LogDebug("Set all calendars flag for a unified calendar.");
-               calendarFilter->setCalendarId(CALENDAR_BOOK_FILTER_ALL, true);
+                               calendarFilter->setCalendarId(CALENDAR_BOOK_FILTER_ALL, true);
                        } else {
                                LogDebug("Set additional calendar id: "<<calendarId);
                calendarFilter->setCalendarId(calendarId, true);
@@ -734,7 +735,7 @@ void Calendar::OnRequestReceived(const IEventFindEventsPtr &event)
                } else {
                        if(getIsUnified()) {
                                LogDebug("Set all calendars flag for a unified calendar.");
-               calendarFilter->setCalendarId(CALENDAR_BOOK_FILTER_ALL, false);
+                               calendarFilter->setCalendarId(CALENDAR_BOOK_FILTER_ALL, false);
                        } else {
                    LogDebug("Set calendar id: "<<calendarId);
                calendarFilter->setCalendarId(calendarId, false);
index 8401e88..eab3260 100755 (executable)
@@ -881,10 +881,8 @@ CalendarEventPtr CalendarConverter::toItem(const JSValueRef value, bool updateMo
         result->setAttendees(attendees);
     }
     if (!JSValueIsUndefined(m_context, geolocationData)) {
-        DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation =
-            DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(m_context, geolocationData);
-        result->setLatitude(geoLocation->getLatitude());
-        result->setLongitude(geoLocation->getLongitude());
+        DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation = DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(m_context, geolocationData);
+        result->setGeolocation(geoLocation);
     }
     if (!JSValueIsUndefined(m_context, visibilityData)) {
         result->setVisibility(toEventVisibility(toString(visibilityData)));
index fd2e9b3..91cdf32 100755 (executable)
@@ -43,8 +43,7 @@ CalendarEvent::CalendarEvent():
     m_attendees(new EventAttendeeList()),
     m_isDetached(false),
     m_attributesOfInterest(new AttributeList()),
-    m_latitude(UNDEFINED_GEO),
-    m_longitude(UNDEFINED_GEO),
+    m_geolocation(new DeviceAPI::Tizen::SimpleCoordinates(UNDEFINED_GEO, UNDEFINED_GEO)),
     m_timeZone(DEFAULT_TIMEZONE),
     m_priority(LOW_PRIORITY),
     m_createdDate(UNDEFINED_TIME),
@@ -138,8 +137,8 @@ CalendarEvent::CalendarEvent(const CalendarEvent &original)
     m_attributesOfInterest = attributesPtr;
     *m_attributesOfInterest = *(original.getAttributesOfInterest());
 
-    m_latitude = original.getLatitude();
-    m_longitude = original.getLongitude();
+    DeviceAPI::Tizen::SimpleCoordinatesPtr geolocationPtr( new DeviceAPI::Tizen::SimpleCoordinates(original.getGeolocation()->getLatitude(), original.getGeolocation()->getLongitude()));
+    m_geolocation = geolocationPtr;
 
     m_timeZone = original.getTimeZone();
     m_priority = original.getPriority();
@@ -438,24 +437,14 @@ void CalendarEvent::setAttributesOfInterest(AttributeListPtr value)
     m_attributesOfInterest = value;
 }
 
-double CalendarEvent::getLatitude() const
+DeviceAPI::Tizen::SimpleCoordinatesPtr CalendarEvent::getGeolocation() const
 {
-    return m_latitude;
+    return m_geolocation;
 }
 
-void CalendarEvent::setLatitude(double value)
+void CalendarEvent::setGeolocation(DeviceAPI::Tizen::SimpleCoordinatesPtr value)
 {
-    m_latitude = value;
-}
-
-double CalendarEvent::getLongitude() const
-{
-    return m_longitude;
-}
-
-void CalendarEvent::setLongitude(double value)
-{
-    m_longitude = value;
+    m_geolocation = value;
 }
 
 std::string CalendarEvent::getTimeZone() const
index 6373b20..c6ad12f 100755 (executable)
@@ -29,6 +29,7 @@
 #include "EventRecurrenceRule.h"
 
 #include <JavaScriptCore/JavaScript.h>
+#include "SimpleCoordinates.h"
 
 namespace DeviceAPI {
 namespace Calendar {
@@ -173,11 +174,8 @@ class CalendarEvent
     void setAttributesOfInterest(AttributeListPtr value);
     AttributeListPtr getAttributesOfInterest() const;
 
-    double getLatitude() const;
-    void setLatitude(double value);
-
-    double getLongitude() const;
-    void setLongitude(double value);
+    DeviceAPI::Tizen::SimpleCoordinatesPtr getGeolocation() const;
+    void setGeolocation(DeviceAPI::Tizen::SimpleCoordinatesPtr value);
 
     void setTimeZone(std::string value);
     std::string getTimeZone() const;
@@ -224,8 +222,7 @@ class CalendarEvent
     EventAttendeeListPtr m_attendees;
     bool m_isDetached;
     AttributeListPtr m_attributesOfInterest;
-    double m_latitude;
-    double m_longitude;
+       DeviceAPI::Tizen::SimpleCoordinatesPtr m_geolocation;
     std::string m_timeZone;
     TaskPriority m_priority;
     long long int m_createdDate;
index 440e646..b3348bf 100755 (executable)
 
 #include <dpl/log/log.h>
 #include "CalendarFilter.h"
+#include <Commons/Exception.h>
 #include <calendar2.h>
 #include <map>
 #include <sstream>
-#include <time.h>
+#include <ctime>
 
 #include "CalendarUtility.h"
 
@@ -86,6 +87,7 @@ CalendarFilter::CalendarFilter()
     m_normalInstanceRecordCount = 0;
     m_alldayInstanceRecordList = NULL;
     m_alldayInstanceRecordCount = 0;
+       m_calendarId = UNDEFINED_CALENDAR_ID;
 }
 
 CalendarFilter::~CalendarFilter()
@@ -170,7 +172,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
             || CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY==attrName) {
             value = convertStringToIntValue(attrName, matchValue->getString());
         } else {
-            value = matchValue->getInt();
+            value = matchValue->getLong();
         }
 
         if(CalendarEvent::TASK_TYPE==m_type) {
@@ -197,7 +199,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
         LogDebug("Added int filter with id: "<<id);
     } else if(CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE==attrName) {
-               std::time_t time = matchValue->getTimeT();
+               std::time_t time = getTimeTFromTZDateAny(matchValue);
         if(CalendarEvent::TASK_TYPE==m_type) {
             calendar_filter_add_lli(m_filter, m_taskAttributeMap[attrName], intMatchFlag, (long long int) time);
         } else {
@@ -225,7 +227,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
         CALENDAR_FILTER_ATTRIBUTE_DUE_DATE==attrName ||
         CALENDAR_FILTER_ATTRIBUTE_END_DATE==attrName) {
         calendar_time_s calTime = {CALENDAR_TIME_UTIME, {0}};
-        std::time_t time = matchValue->getTimeT();
+        std::time_t time = getTimeTFromTZDateAny(matchValue);
         calTime.time.utime = (long long int) time;
         if(CalendarEvent::TASK_TYPE==m_type) {
             calendar_filter_add_caltime(m_filter, m_taskAttributeMap[attrName], intMatchFlag, calTime);
@@ -287,8 +289,8 @@ void CalendarFilter::visitAttribute(std::string& attrName, DeviceAPI::Tizen::Mat
                                if( matchValue->isNullOrUndefined() ) {
                            calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_EQUAL, 0);
                                } else {
-            calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0);
-        }
+                       calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0);
+                       }
                        LogDebug("Added int filter for rrule EXACTLY flag.");
                        } else {
                    calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN, 0);
@@ -319,12 +321,12 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen
         calendar_time_s startTimeAllday = {CALENDAR_TIME_LOCALTIME, {0}};
         calendar_time_s endTimeAllday = {CALENDAR_TIME_LOCALTIME, {0}};
         if (!initialValue->isNullOrUndefined()) {
-            startTime.time.utime = (long long int) (initialValue->getTimeT());
-                       startTimeAllday.time.date = CalendarUtility::LLIToCalTime(NULL, (long long int) (initialValue->getTimeT())).time.date;
+            startTime.time.utime = (long long int) (getTimeTFromTZDateAny(initialValue));
+                       startTimeAllday.time.date = CalendarUtility::LLIToCalTime(NULL, (long long int) (getTimeTFromTZDateAny(initialValue))).time.date;
         }
         if (!endValue->isNullOrUndefined()) {
-            endTime.time.utime = (long long int) (endValue->getTimeT());
-                       endTimeAllday.time.date = CalendarUtility::LLIToCalTime(NULL, (long long int) (endValue->getTimeT())).time.date;
+            endTime.time.utime = (long long int) (getTimeTFromTZDateAny(endValue));
+                       endTimeAllday.time.date = CalendarUtility::LLIToCalTime(NULL, (long long int) (getTimeTFromTZDateAny(endValue))).time.date;
         }
         if(CalendarEvent::TASK_TYPE==m_type) {
                        calendar_filter_h subFilter = NULL;
@@ -412,6 +414,11 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen
 
                        int ret;
                        LogDebug("Query for normal instances.");
+                       if(UNDEFINED_CALENDAR_ID!=m_calendarId) {
+                               LogDebug("Set the calendar id for normal instances: "<<m_calendarId);
+                       calendar_filter_add_operator(normalFilter, CALENDAR_FILTER_OPERATOR_AND);
+                       calendar_filter_add_int(normalFilter, _calendar_instance_normal_calendar_book.calendar_book_id, CALENDAR_MATCH_EQUAL, m_calendarId);
+                       }
                        ret = calendar_query_set_filter(normalQuery, normalFilter);
                        if( CALENDAR_ERROR_NONE!=ret ) {
                                ThrowMsg(PlatformException, "Setting a normal filter failed: "<<ret);
@@ -426,7 +433,13 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen
                        } else {
                                LogDebug("Normal instance item count: "<<m_normalInstanceRecordCount);
                        }
+
                        LogDebug("Query for allday instances.");
+                       if(UNDEFINED_CALENDAR_ID!=m_calendarId) {
+                               LogDebug("Set the calendar id for allday instances: "<<m_calendarId);
+                       calendar_filter_add_operator(alldayFilter, CALENDAR_FILTER_OPERATOR_AND);
+                       calendar_filter_add_int(alldayFilter, _calendar_instance_allday_calendar_book.calendar_book_id, CALENDAR_MATCH_EQUAL, m_calendarId);
+                       }
                        ret = calendar_query_set_filter(alldayQuery, alldayFilter);
                        if( CALENDAR_ERROR_NONE!=ret ) {
                                ThrowMsg(PlatformException, "Setting an allday filter failed: "<<ret);
@@ -442,6 +455,8 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen
                                LogDebug("Allday instance item count: "<<m_alldayInstanceRecordCount);
                        }
 
+
+
                        LogDebug("Free queries and filters.");
                        if(normalQuery) {
                                calendar_query_destroy(normalQuery);
@@ -485,49 +500,49 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen
         CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE==attrName) {
         if(CalendarEvent::TASK_TYPE==m_type) {
             if (!initialValue->isNullOrUndefined()) {
-                calendar_filter_add_lli(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, (long long int)(initialValue->getTimeT()));
+                calendar_filter_add_lli(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, (long long int)(getTimeTFromTZDateAny(initialValue)));
             }
             if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) {
                 calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_AND);
             }
             if (!endValue->isNullOrUndefined()) {
-                calendar_filter_add_lli(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, (long long int)(endValue->getTimeT()));
+                calendar_filter_add_lli(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, (long long int)(getTimeTFromTZDateAny(endValue)));
             }
         } else {
             if (!initialValue->isNullOrUndefined()) {
-                calendar_filter_add_lli(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, (long long int)(initialValue->getTimeT()));
+                calendar_filter_add_lli(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, (long long int)(getTimeTFromTZDateAny(initialValue)));
             }
             if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) {
                 calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_AND);
             }
             if (!endValue->isNullOrUndefined()) {
-                calendar_filter_add_lli(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, (long long int)(endValue->getTimeT()));
+                calendar_filter_add_lli(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, (long long int)(getTimeTFromTZDateAny(endValue)));
             }
         }
-        LogDebug("Added lli range filter with initial value: "<<initialValue->getTimeT()<<", end value: "<<endValue->getTimeT());
+        LogDebug("Added lli range filter with initial value: "<<getTimeTFromTZDateAny(initialValue)<<", end value: "<<getTimeTFromTZDateAny(endValue));
     } else if(CALENDAR_FILTER_ATTRIBUTE_PROGRESS==attrName) {
         if(CalendarEvent::TASK_TYPE==m_type) {
             if (!initialValue->isNullOrUndefined()) {
-                calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, initialValue->getInt());
+                calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, initialValue->getLong());
             }
             if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) {
                 calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_AND);
             }
             if (!endValue->isNullOrUndefined()) {
-                calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endValue->getInt());
+                calendar_filter_add_int(m_filter, m_taskAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endValue->getLong());
             }
         } else {
             if (!initialValue->isNullOrUndefined()) {
-                calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, initialValue->getInt());
+                calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, initialValue->getLong());
             }
             if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) {
                 calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_AND);
             }
             if (!endValue->isNullOrUndefined()) {
-                calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endValue->getInt());
+                calendar_filter_add_int(m_filter, m_eventAttributeMap[attrName], CALENDAR_MATCH_LESS_THAN_OR_EQUAL, endValue->getLong());
             }
         }
-        LogDebug("Added double range filter with initial value: "<<initialValue->getInt()<<", end value: "<<endValue->getInt());
+        LogDebug("Added double range filter with initial value: "<<initialValue->getLong()<<", end value: "<<endValue->getLong());
     } else {
         LogWarning("Not supported filter attribute: "<<attrName);
     }
@@ -556,19 +571,29 @@ void CalendarFilter::setCalendarId(int calendarId, bool isFilterSet)
 
     if(CalendarEvent::TASK_TYPE==m_type) {
                if(CALENDAR_BOOK_FILTER_ALL==calendarId) {
-               calendar_filter_add_int(m_filter, _calendar_todo.calendar_book_id, CALENDAR_MATCH_GREATER_THAN, calendarId);
+                       calendar_filter_add_int(m_filter, _calendar_todo.calendar_book_id, CALENDAR_MATCH_GREATER_THAN, calendarId);
                } else {
                calendar_filter_add_int(m_filter, _calendar_todo.calendar_book_id, CALENDAR_MATCH_EQUAL, calendarId);
                }
+
+        calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_AND);
+        calendar_filter_add_int(m_filter, _calendar_todo.is_deleted, CALENDAR_MATCH_EQUAL, 0);
     } else {
-               if(CALENDAR_BOOK_FILTER_ALL==calendarId) {
+               if(CALENDAR_BOOK_FILTER_ALL==calendarId) {
                        calendar_filter_add_int(m_filter, _calendar_event.calendar_book_id, CALENDAR_MATCH_GREATER_THAN, calendarId);
                } else {
                calendar_filter_add_int(m_filter, _calendar_event.calendar_book_id, CALENDAR_MATCH_EQUAL, calendarId);
                }
+        calendar_filter_add_operator(m_filter, CALENDAR_FILTER_OPERATOR_AND);
+        calendar_filter_add_int(m_filter, _calendar_event.is_deleted, CALENDAR_MATCH_EQUAL, 0);
     }
 }
 
+void CalendarFilter::setCalendarIdForEvent(int calendarId)
+{
+       m_calendarId = calendarId;
+}
+
 void CalendarFilter::setSortMode(DeviceAPI::Tizen::SortModeArrayPtr attr)
 {
        std::string attrName;
@@ -709,5 +734,12 @@ int CalendarFilter::convertStringToIntValue(const std::string attrName, const st
     return -1;
 }
 
+std::time_t CalendarFilter::getTimeTFromTZDateAny(DeviceAPI::Tizen::AnyPtr &any) const
+{
+       std::time_t *pt = static_cast<time_t*>(any->getPriv());
+
+       return *pt;
+}
+
 }
 }
index 6c94ba6..5af1540 100755 (executable)
@@ -68,6 +68,7 @@ private:
     int m_normalInstanceRecordCount;
     calendar_list_h m_alldayInstanceRecordList;
     int m_alldayInstanceRecordCount;
+       int m_calendarId;
 
        static std::map<std::string, unsigned int> m_eventAttributeMap;
        static std::map<std::string, unsigned int> m_taskAttributeMap;
@@ -95,6 +96,7 @@ public:
     void setType(CalendarEvent::CalendarType type);
 
     void setCalendarId(int calendarId, bool isFilterSet);
+    void setCalendarIdForEvent(int calendarId);
 
        void setSortMode(DeviceAPI::Tizen::SortModeArrayPtr attr);
 
@@ -114,6 +116,8 @@ public:
 
 private:
        int convertStringToIntValue(const std::string attrName, const std::string valueString);
+
+       std::time_t getTimeTFromTZDateAny(DeviceAPI::Tizen::AnyPtr &any) const;
 };
 
 typedef DPL::SharedPtr<CalendarFilter> CalendarFilterPtr;
diff --git a/src/Calendar/CalendarFilterConverter.cpp b/src/Calendar/CalendarFilterConverter.cpp
new file mode 100644 (file)
index 0000000..ec40f3a
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file        CalendarFilterConverter.cpp
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @description        Reference from CalendarConverter.cpp
+ */
+
+#include "CalendarFilterConverter.h"
+
+#include <dpl/log/log.h>
+#include <TimeUtilConverter.h>
+#include <JSTZDate.h>
+#include "CalendarFilter.h"
+
+namespace DeviceAPI {
+namespace Calendar {
+
+using namespace DeviceAPI::Tizen;
+using namespace DeviceAPI::Time;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+using namespace std;
+
+static PropertyStructArray properties =
+{
+               { CALENDAR_FILTER_ATTRIBUTE_ID_UID,             PrimitiveType_String},
+               { CALENDAR_FILTER_ATTRIBUTE_ID,                 PrimitiveType_String},
+               { CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE, PrimitiveType_PlatformObject},
+               { CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION,        PrimitiveType_String},
+               { CALENDAR_FILTER_ATTRIBUTE_SUMMARY,            PrimitiveType_String},
+               { CALENDAR_FILTER_ATTRIBUTE_START_DATE,         PrimitiveType_PlatformObject},
+               { CALENDAR_FILTER_ATTRIBUTE_LOCATION,           PrimitiveType_String},
+               { CALENDAR_FILTER_ATTRIBUTE_LATITUDE,           PrimitiveType_Double},
+               { CALENDAR_FILTER_ATTRIBUTE_LONGITUDE,          PrimitiveType_Double},
+               { CALENDAR_FILTER_ATTRIBUTE_ORGANIZER,          PrimitiveType_String},
+               { CALENDAR_FILTER_ATTRIBUTE_VISIBILITY,         PrimitiveType_String},
+               { CALENDAR_FILTER_ATTRIBUTE_STATUS,             PrimitiveType_String},
+               { CALENDAR_FILTER_ATTRIBUTE_CATEGORIES,         PrimitiveType_String},
+               { CALENDAR_FILTER_ATTRIBUTE_PRIORITY,           PrimitiveType_String},
+               { CALENDAR_FILTER_ATTRIBUTE_DUE_DATE,           PrimitiveType_PlatformObject},
+               { CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED,        PrimitiveType_Boolean},
+               { CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY,         PrimitiveType_Boolean},
+               { CALENDAR_FILTER_ATTRIBUTE_END_DATE,           PrimitiveType_PlatformObject},
+               { CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE,     PrimitiveType_PlatformObject},
+               { CALENDAR_FILTER_ATTRIBUTE_PROGRESS,           PrimitiveType_Long},
+               { CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY,       PrimitiveType_String},
+               { CALENDAR_FILTER_ATTRIBUTE_RECURRENCE_RULE,    PrimitiveType_Null},
+               { CALENDAR_FILTER_ATTRIBUTE_ALARMS,             PrimitiveType_Null},
+               { CALENDAR_FILTER_ATTRIBUTE_ATTENDEES,          PrimitiveType_Null},
+               { 0,                                            PrimitiveType_NoType}
+};
+
+set<string> CalendarFilterConverter::sCustomAttributeNames = {
+               "lastModificationDate", "startDate", "endDate", "dueDate", "completedDate"
+};
+
+CalendarFilterConverter::CalendarFilterConverter(JSContextRef context) :
+               FilterConverter(context, properties, false)
+{
+       LogDebug("entered");
+}
+
+CalendarFilterConverter::~CalendarFilterConverter()
+{
+       LogDebug("entered");
+}
+
+void CalendarFilterConverter::toAnyCustom(const JSValueRef& arg, const std::string &attrName, AnyPtr& any) const
+{
+       if(sCustomAttributeNames.find(attrName) == sCustomAttributeNames.end())
+               return;
+
+       if(JSValueIsObjectOfClass(m_context, arg, DeviceAPI::Time::JSTZDate::getClassRef()))
+       {
+               DeviceAPI::Time::TimeUtilConverter timeConverter(m_context);
+
+               time_t *ptTime = new time_t;
+               tm tmTime = timeConverter.toTZDateTime(arg);
+               *ptTime = mktime(&tmTime);
+               any->setPriv(static_cast<void *>(ptTime), true);
+       }
+}
+
+} // Tizen
+} // DeviceAPI
+
diff --git a/src/Calendar/CalendarFilterConverter.h b/src/Calendar/CalendarFilterConverter.h
new file mode 100644 (file)
index 0000000..1bd3d7a
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file        CalendarFilterConverter.h
+ * @version     0.1
+ * @description        Reference from CalendarConverter.h
+ */
+
+#ifndef _TIZEN_CALENDAR_FILTER_CONVERTER_H_
+#define _TIZEN_CALENDAR_FILTER_CONVERTER_H_
+
+#include <set>
+#include <string>
+#include <FilterConverter.h>
+
+namespace DeviceAPI {
+namespace Calendar {
+
+class CalendarFilterConverter : public DeviceAPI::Tizen::FilterConverter
+{
+public:
+       explicit CalendarFilterConverter(JSContextRef context);
+       virtual ~CalendarFilterConverter();
+
+       virtual void toAnyCustom(const JSValueRef& arg, const std::string &attrName, DeviceAPI::Tizen::AnyPtr& any) const;
+
+private:
+       static std::set<std::string> sCustomAttributeNames;
+};
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<CalendarFilterConverter> CalendarFilterConverterFactory;
+
+} // Calendar
+} // DeviceAPI
+
+#endif // _TIZEN_CALENDAR_FILTER_CONVERTER_H_
+
index d732265..a28ab1d 100755 (executable)
@@ -18,6 +18,7 @@
 
 #include "CalendarFilterValidator.h"
 #include "CalendarFilter.h"
+#include <JSTZDate.h>
 
 namespace DeviceAPI {
 namespace Calendar {
@@ -28,10 +29,10 @@ static PropertyStructArray properties =
 {
     {CALENDAR_FILTER_ATTRIBUTE_ID_UID,              PrimitiveType_String},
     {CALENDAR_FILTER_ATTRIBUTE_ID,                     PrimitiveType_String},
-    {CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE,  PrimitiveType_Time},
+    {CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE,  PrimitiveType_PlatformObject},
     {CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION,         PrimitiveType_String},
     {CALENDAR_FILTER_ATTRIBUTE_SUMMARY,             PrimitiveType_String},
-    {CALENDAR_FILTER_ATTRIBUTE_START_DATE,          PrimitiveType_Time},
+    {CALENDAR_FILTER_ATTRIBUTE_START_DATE,          PrimitiveType_PlatformObject},
     {CALENDAR_FILTER_ATTRIBUTE_LOCATION,            PrimitiveType_String},
     {CALENDAR_FILTER_ATTRIBUTE_LATITUDE,            PrimitiveType_Double},
     {CALENDAR_FILTER_ATTRIBUTE_LONGITUDE,           PrimitiveType_Double},
@@ -40,12 +41,12 @@ static PropertyStructArray properties =
     {CALENDAR_FILTER_ATTRIBUTE_STATUS,              PrimitiveType_String},
     {CALENDAR_FILTER_ATTRIBUTE_CATEGORIES,          PrimitiveType_String},
     {CALENDAR_FILTER_ATTRIBUTE_PRIORITY,            PrimitiveType_String},
-    {CALENDAR_FILTER_ATTRIBUTE_DUE_DATE,            PrimitiveType_Time},
+    {CALENDAR_FILTER_ATTRIBUTE_DUE_DATE,            PrimitiveType_PlatformObject},
        {CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED,                 PrimitiveType_Boolean},
     {CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY,          PrimitiveType_Boolean},
-    {CALENDAR_FILTER_ATTRIBUTE_END_DATE,            PrimitiveType_Time},
-    {CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE,      PrimitiveType_Time},
-    {CALENDAR_FILTER_ATTRIBUTE_PROGRESS,               PrimitiveType_Integer},
+    {CALENDAR_FILTER_ATTRIBUTE_END_DATE,            PrimitiveType_PlatformObject},
+    {CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE,      PrimitiveType_PlatformObject},
+    {CALENDAR_FILTER_ATTRIBUTE_PROGRESS,               PrimitiveType_Long},
     {CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY,        PrimitiveType_String},
     {CALENDAR_FILTER_ATTRIBUTE_RECURRENCE_RULE,     PrimitiveType_Null},
     {CALENDAR_FILTER_ATTRIBUTE_ALARMS,                         PrimitiveType_Null},
@@ -53,10 +54,39 @@ static PropertyStructArray properties =
     {0,        PrimitiveType_NoType}
 };
 
+class CalendarFilterValidator : public FilterValidator
+{
+public:
+       CalendarFilterValidator(PropertyStructArray properties) : FilterValidator(properties) {}
+
+       virtual ~CalendarFilterValidator() {};
+
+       virtual bool validateAttributeCustom(std::string& attrName,
+                       MatchFlag& matchFlag, AnyPtr& matchValue, int depth)
+       {
+               if(matchValue->getPriv() == NULL)
+                       return false;
+
+               return true;
+       }
+
+       virtual bool validateAttributeRangeCustom(std::string& attrName,
+                       AnyPtr& initialValue, AnyPtr& endValue, int depth)
+       {
+               if(!initialValue->isNullOrUndefined() && initialValue->getPriv() == NULL)
+                       return false;
+
+               if(!endValue->isNullOrUndefined() && initialValue->getPriv() == NULL)
+                       return false;
+
+               return true;
+       }
+};
+
 FilterValidatorPtr CalendarFilterValidatorFactory::getCalendarFilterValidator()
 {
     static FilterValidatorPtr theInstance =
-               FilterValidatorPtr(new FilterValidator(properties));
+               FilterValidatorPtr(new CalendarFilterValidator(properties));
     return theInstance;
 }
 
index 751da02..4f7bf52 100755 (executable)
@@ -48,7 +48,7 @@ EventRecurrenceRule::~EventRecurrenceRule()
                LogDebug("Unprotect JS daysOfTheWeek.");
                JSValueUnprotect(m_context, m_daysOfTheWeekJSRef);
        }
-       if(m_daysOfTheWeekJSRef) {
+       if(m_setPositionsJSRef) {
                LogDebug("Unprotect JS setPositions.");
                JSValueUnprotect(m_context, m_setPositionsJSRef);
        }
index b64ab3c..7ae384b 100755 (executable)
@@ -1132,18 +1132,18 @@ void EventWrapper::setPositionToPlatformEvent()
 {
     int ret;
     if(CalendarEvent::TASK_TYPE==getType()) {
-        ret = calendar_record_set_double(m_platformEvent, _calendar_todo.latitude, m_abstractEvent->getLatitude());
+        ret = calendar_record_set_double(m_platformEvent, _calendar_todo.latitude, m_abstractEvent->getGeolocation()->getLatitude());
     } else {
-        ret = calendar_record_set_double(m_platformEvent, _calendar_event.latitude, m_abstractEvent->getLatitude());
+        ret = calendar_record_set_double(m_platformEvent, _calendar_event.latitude, m_abstractEvent->getGeolocation()->getLatitude());
     }
     if (CALENDAR_ERROR_NONE != ret) {
         LogWarning("Can't set latitude: "<<ret);
     }
 
     if(CalendarEvent::TASK_TYPE==getType()) {
-        ret = calendar_record_set_double(m_platformEvent, _calendar_todo.longitude, m_abstractEvent->getLongitude());
+        ret = calendar_record_set_double(m_platformEvent, _calendar_todo.longitude, m_abstractEvent->getGeolocation()->getLongitude());
     } else {
-        ret = calendar_record_set_double(m_platformEvent, _calendar_event.longitude, m_abstractEvent->getLongitude());
+        ret = calendar_record_set_double(m_platformEvent, _calendar_event.longitude, m_abstractEvent->getGeolocation()->getLongitude());
     }
 
     if (CALENDAR_ERROR_NONE != ret) {
@@ -2188,7 +2188,7 @@ void EventWrapper::setPositionFromPlatformEvent()
         LogWarning("Can't get item latitude.");
         return;
     }
-    m_abstractEvent->setLatitude(value);
+    m_abstractEvent->getGeolocation()->setLatitude(value);
 
     if(CalendarEvent::TASK_TYPE==getType()) {
         ret = calendar_record_get_double(m_platformEvent, _calendar_todo.longitude, &value);
@@ -2199,7 +2199,7 @@ void EventWrapper::setPositionFromPlatformEvent()
         LogWarning("Can't get item longitude.");
         return;
     }
-    m_abstractEvent->setLongitude(value);
+    m_abstractEvent->getGeolocation()->setLongitude(value);
 }
 
 void EventWrapper::setPriorityFromPlatformEvent()
index 133dc72..2026920 100755 (executable)
@@ -30,7 +30,6 @@
 #include <JSTizenException.h>
 #include <JSTizenExceptionFactory.h>
 #include <SecurityExceptions.h>
-#include <FilterConverter.h>
 #include <TimeUtilConverter.h>
 
 #include "JSCalendarManager.h"
@@ -43,6 +42,7 @@
 #include "plugin_config.h"
 #include "CalendarResponseDispatcher.h"
 #include "CalendarMultiCallback.h"
+#include "CalendarFilterConverter.h"
 
 #include "CalendarAsyncCallbackManager.h"
 #include "CalendarListenerManager.h"
@@ -78,12 +78,9 @@ JSClassDefinition JSCalendar::m_classInfo = {
 };
 
 JSStaticValue JSCalendar::m_property[] = {
-    { TIZEN_CALENDAR_PROPERTY_NAME, JSCalendar::getPropertyName,
-      NULL, kJSPropertyAttributeReadOnly },
-    /*{ TIZEN_CALENDAR_PROPERTY_ACCOUNT_SERVICE_ID, JSCalendar::getPropertyAccountServiceId,
-      NULL, kJSPropertyAttributeReadOnly },*/
-    { TIZEN_CALENDAR_PROPERTY_ID, JSCalendar::getPropertyId,
-      NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_CALENDAR_PROPERTY_NAME, JSCalendar::getPropertyName, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+    /*{ TIZEN_CALENDAR_PROPERTY_ACCOUNT_SERVICE_ID, JSCalendar::getPropertyAccountServiceId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },*/
+    { TIZEN_CALENDAR_PROPERTY_ID, JSCalendar::getPropertyId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { 0, 0, 0, 0 }
 };
 
@@ -716,7 +713,8 @@ JSValueRef JSCalendar::find(JSContextRef context,
 
         Validator validator(context, exception);
         CalendarConverter converter(context);
-        DeviceAPI::Tizen::FilterConverterFactory::ConverterType filterConverter = DeviceAPI::Tizen::FilterConverterFactory::getConverter(context);
+        CalendarFilterConverterFactory::ConverterType filterConverter =
+                       CalendarFilterConverterFactory::ConverterType(new CalendarFilterConverter(context));
 
         if (argumentCount<1) {
             ThrowMsg(ConversionException, "Wrong parameter type.");
index 0dadf47..fed108b 100755 (executable)
@@ -303,8 +303,8 @@ bool JSCalendarAlarm::setProperty(JSContextRef context,
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
     }
-    DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
-    return false;
+
+    return true;
 }
 
 }
index 67c0beb..397ba7b 100755 (executable)
@@ -327,8 +327,8 @@ bool JSCalendarAttendee::setProperty(JSContextRef context,
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
     }
-    JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
-    return false;
+
+    return true;
 }
 
 }
index aa126fd..b376b6a 100755 (executable)
@@ -70,9 +70,9 @@ JSClassDefinition JSCalendarEvent::m_classInfo = {
 };
 
 JSStaticValue JSCalendarEvent::m_property[] = {
-    { TIZEN_CALENDAR_EVENT_ID, getPropertyId, NULL, kJSPropertyAttributeReadOnly },
-    { TIZEN_CALENDAR_EVENT_IS_DETACHED, getPropertyIsDetached, NULL, kJSPropertyAttributeReadOnly },
-    { TIZEN_CALENDAR_EVENT_RECURRENCE_RULE, getPropertyRecurrenceRule, setPropertyRecurrenceRule, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_EVENT_ID, getPropertyId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+    { TIZEN_CALENDAR_EVENT_IS_DETACHED, getPropertyIsDetached, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+    { TIZEN_CALENDAR_EVENT_RECURRENCE_RULE, getPropertyRecurrenceRule, setPropertyRecurrenceRule, kJSPropertyAttributeNone | kJSPropertyAttributeDontDelete },
 
     { 0, 0, 0, 0 }
 };
@@ -467,10 +467,9 @@ bool JSCalendarEvent::setPropertyRecurrenceRule(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 }
index 09e7397..662aa89 100755 (executable)
@@ -26,7 +26,6 @@
 #include <JSTZDate.h>
 #include <sstream>
 
-
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace DeviceAPI::Common;
@@ -259,8 +258,8 @@ bool JSCalendarEventId::setProperty(JSContextRef context,
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
     }
-    JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
-    return false;
+
+    return true;
 }
 
 }
index ae7591c..646bc5b 100755 (executable)
@@ -94,8 +94,8 @@ JSStaticValue JSCalendarItemProperties::m_property[] = {
     { TIZEN_CALENDAR_TASK_PROGRESS, getPropertyProgress, setPropertyProgress, kJSPropertyAttributeNone },
     { TIZEN_CALENDAR_ITEM_PRIORITY, getPropertyPriority, setPropertyPriority, kJSPropertyAttributeNone },
     { TIZEN_CALENDAR_EVENT_END_DATE, getPropertyEndDate, setPropertyEndDate, kJSPropertyAttributeNone },
-    { TIZEN_CALENDAR_EVENT_LAST_MODIFICATION_DATE, getPropertyLastModificationDate, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_CALENDAR_ITEM_CALENDAR_ID, getPropertyCalendarId, NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_CALENDAR_EVENT_LAST_MODIFICATION_DATE, getPropertyLastModificationDate, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_CALENDAR_ITEM_CALENDAR_ID, getPropertyCalendarId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
 
     { 0, 0, 0, 0 }
 };
@@ -366,10 +366,9 @@ bool JSCalendarItemProperties::setPropertyDescription(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertySummary(JSContextRef context,
@@ -407,10 +406,9 @@ bool JSCalendarItemProperties::setPropertySummary(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyStartTime(JSContextRef context,
@@ -469,10 +467,9 @@ bool JSCalendarItemProperties::setPropertyStartTime(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyLocation(JSContextRef context,
@@ -510,10 +507,9 @@ bool JSCalendarItemProperties::setPropertyLocation(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyCategories(JSContextRef context,
@@ -564,10 +560,9 @@ bool JSCalendarItemProperties::setPropertyCategories(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyStatus(JSContextRef context,
@@ -608,10 +603,9 @@ bool JSCalendarItemProperties::setPropertyStatus(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyAlarms(JSContextRef context,
@@ -661,10 +655,9 @@ bool JSCalendarItemProperties::setPropertyAlarms(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyOrganizer(JSContextRef context,
@@ -702,10 +695,9 @@ bool JSCalendarItemProperties::setPropertyOrganizer(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyVisibility(JSContextRef context,
@@ -746,10 +738,9 @@ bool JSCalendarItemProperties::setPropertyVisibility(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyGeolocation(JSContextRef context,
@@ -759,10 +750,12 @@ JSValueRef JSCalendarItemProperties::getPropertyGeolocation(JSContextRef context
 {
     Try
     {
-        CalendarEventPtr event = getPrivateObject(object);
-        DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation( new DeviceAPI::Tizen::SimpleCoordinates(event->getLatitude(), event->getLongitude()) );
-
-        return DeviceAPI::Tizen::JSSimpleCoordinates::createJSObject(context, geoLocation);
+        CalendarEventPtr item = getPrivateObject(object);
+       if( UNDEFINED_GEO==item->getGeolocation()->getLatitude() ) {
+                       return JSValueMakeUndefined(context);
+               } else {
+                       return DeviceAPI::Tizen::JSSimpleCoordinates::createJSObject(context, item->getGeolocation());
+               }
     }
     Catch(Exception)
     {
@@ -780,26 +773,24 @@ bool JSCalendarItemProperties::setPropertyGeolocation(JSContextRef context,
 {
     Try
     {
-        CalendarEventPtr event = getPrivateObject(object);
+        CalendarEventPtr item = getPrivateObject(object);
 
                if (JSValueIsNull(context, value) || JSValueIsUndefined(context, value)) {
-               event->setLatitude(UNDEFINED_GEO);
-               event->setLongitude(UNDEFINED_GEO);
+               item->getGeolocation()->setLatitude(UNDEFINED_GEO);
+               item->getGeolocation()->setLongitude(UNDEFINED_GEO);
                } else {
                DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation = DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(context, value);
 
-               event->setLatitude(geoLocation->getLatitude());
-               event->setLongitude(geoLocation->getLongitude());
+               item->setGeolocation(geoLocation);
                }
         return true;
     }
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyDuration(JSContextRef context,
@@ -859,10 +850,9 @@ bool JSCalendarItemProperties::setPropertyDuration(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyIsAllDay(JSContextRef context,
@@ -899,10 +889,9 @@ bool JSCalendarItemProperties::setPropertyIsAllDay(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyAvailability(JSContextRef context,
@@ -943,10 +932,9 @@ bool JSCalendarItemProperties::setPropertyAvailability(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyAttendees(JSContextRef context,
@@ -994,10 +982,9 @@ bool JSCalendarItemProperties::setPropertyAttendees(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyDueDate(JSContextRef context,
@@ -1064,10 +1051,9 @@ bool JSCalendarItemProperties::setPropertyDueDate(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyCompletedDate(JSContextRef context,
@@ -1134,10 +1120,9 @@ bool JSCalendarItemProperties::setPropertyCompletedDate(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyProgress(JSContextRef context,
@@ -1183,10 +1168,9 @@ bool JSCalendarItemProperties::setPropertyProgress(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyPriority(JSContextRef context,
@@ -1230,10 +1214,9 @@ bool JSCalendarItemProperties::setPropertyPriority(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyEndDate(JSContextRef context,
@@ -1300,10 +1283,9 @@ bool JSCalendarItemProperties::setPropertyEndDate(JSContextRef context,
     Catch(Exception)
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
-    return false;
+    return true;
 }
 
 JSValueRef JSCalendarItemProperties::getPropertyLastModificationDate(JSContextRef context,
index f01ec9d..3be83ac 100755 (executable)
@@ -70,8 +70,7 @@ JSStaticFunction JSCalendarManager::m_function[] = {
     { CALENDAR_FUNCTION_API_GET_CALENDARS, getCalendars, kJSPropertyAttributeNone },
     { CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR, getDefaultCalendar, kJSPropertyAttributeNone },
     { CALENDAR_FUNCTION_API_GET_UNIFIED_CALENDAR, getUnifiedCalendar, kJSPropertyAttributeNone },
-    { CALENDAR_FUNCTION_API_GET_CALENDAR,
-      getCalendar, kJSPropertyAttributeNone },
+    { CALENDAR_FUNCTION_API_GET_CALENDAR, getCalendar, kJSPropertyAttributeNone },
 
     { 0, 0, 0 }
 };
index 30a727e..2473f70 100755 (executable)
@@ -359,8 +359,8 @@ bool JSCalendarRecurrenceRule::setProperty(JSContextRef context,
     {
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
     }
-    JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
-    return false;
+
+    return true;
 }
 
 }
index 3fbcc81..eba4c9c 100755 (executable)
@@ -66,7 +66,7 @@ JSClassDefinition JSCalendarTask::m_classInfo = {
 
 JSStaticValue JSCalendarTask::m_property[] = {
     //Task properties
-    { TIZEN_CALENDAR_TASK_ID, getPropertyId, NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_CALENDAR_TASK_ID, getPropertyId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
 
     { 0, 0, 0, 0 }
 };
index d22c1b6..a433b29 100755 (executable)
@@ -14,7 +14,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
 )
 
@@ -28,6 +27,7 @@ SET(SRCS_IMPL
        CallHistory.cpp
        CallHistoryEntry.cpp
        CallHistoryFilter.cpp
+       CallHistoryFilterConverter.cpp
        CallHistoryMultiCallback.cpp
        CallHistoryStaticController.cpp
        CallHistoryListenerManager.cpp
index bebb11c..90873f8 100755 (executable)
@@ -437,11 +437,17 @@ void CallHistory::OnRequestReceived(const EventFindCallHistoryPtr& event)
                                isAscending = false;
                        }
                        std::string attriName(event->getSortMode()->getAttributeName());
-                       contacts_query_set_sort(query, convertAttrName(attriName), isAscending);
+                       ret = contacts_query_set_sort(query, convertAttrName(attriName), isAscending);
+
                } else {
-                       contacts_query_set_sort(query, _contacts_phone_log.id, isAscending);
+                       ret = contacts_query_set_sort(query, _contacts_phone_log.id, isAscending);
+               }
+
+               if (ret != CONTACTS_ERROR_NONE) {
+                       LogDebug("callhistory query error [" << ret << "]");
                }
 
+
                if (event->getLimitIsSet()) {
                        limit = static_cast<int>(event->getLimit());
                }
@@ -723,41 +729,48 @@ void CallHistory::Watcher::ListenerCB(char* changes)
        CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList());
        StringArrayPtr RemoveListPtr(new StringArray());
 
-       tokenType = strtok( changes, seps );
-       while( tokenType != NULL )
-       {
-       tokenId = strtok( NULL, seps );
+       tokenType = strtok( changes, seps );
+       while( tokenType != NULL )
+       {
+               tokenId = strtok( NULL, seps );
                LogDebug("[ %s / %s ]", tokenType , tokenId );
-               changeType = atoi((const char*)tokenType);
-               changeId = atoi((const char*)tokenId);
+               changeType = atoi((const char*)tokenType);
+               changeId = atoi((const char*)tokenId);
 
 
                contacts_query_h query = NULL;
                contacts_filter_h filter = NULL;
                contacts_list_h recordList = NULL;
-               int ret = 0;
+               int ret = CONTACTS_ERROR_NONE;
 
                contacts_query_create(_contacts_phone_log._uri, &query);
                contacts_filter_create(_contacts_phone_log._uri, &filter);
                contacts_filter_add_int(filter, _contacts_phone_log.id, CONTACTS_MATCH_EQUAL, changeId  );
 
                contacts_query_set_filter(query, filter);
-               contacts_query_set_sort(query, _contacts_phone_log.id, false);
-               ret = contacts_db_get_records_with_query(query, 0, 1, &recordList);
 
+               ret = contacts_query_set_sort(query, _contacts_phone_log.id, false);
                if (ret != CONTACTS_ERROR_NONE) {
                        LogDebug("callhistory query error [" << ret << "]");
+               }
+
+               ret = contacts_db_get_records_with_query(query, 0, 1, &recordList);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       contacts_list_destroy(recordList, true);
+                       contacts_query_destroy(query);
+                       contacts_filter_destroy(filter);
+                       LogDebug("callhistory query error [" << ret << "]");
                        return;
                }
 
-               if((changeType == CONTACTS_CHANGE_INSERTED)||(changeType == CONTACTS_CHANGE_UPDATED)){
+               if((changeType == CONTACTS_CHANGE_INSERTED)||(changeType == CONTACTS_CHANGE_UPDATED)){
                        if (parseRecord(&recordList, callHistoryListPtr)) {
                                if (callHistoryListPtr->size() > 0) {
                                        setCurrentLogId((*callHistoryListPtr)[0]->getEntryId());
                                }
                        }
-               }else if(changeType == CONTACTS_CHANGE_DELETED){
-                       parseRemoveRecord(tokenId, RemoveListPtr);
+               }else if(changeType == CONTACTS_CHANGE_DELETED){
+                       parseRemoveRecord(tokenId, RemoveListPtr);
                }
 
                contacts_list_destroy(recordList, true);
@@ -767,7 +780,7 @@ void CallHistory::Watcher::ListenerCB(char* changes)
                tokenType = strtok( NULL, seps );
        }
 
-       
+
        if((changeType == CONTACTS_CHANGE_INSERTED)||(changeType == CONTACTS_CHANGE_UPDATED)){
                if (callHistoryListPtr->size() > 0) {
                        setCurrentLogId((*callHistoryListPtr)[0]->getEntryId());
@@ -777,7 +790,7 @@ void CallHistory::Watcher::ListenerCB(char* changes)
                        }else if(changeType == CONTACTS_CHANGE_UPDATED){
                                stateHasChanged(callHistoryListPtr, EventCallHistoryListener::CHANGED);
                        }
-                               
+
                }
        }else if(changeType == CONTACTS_CHANGE_DELETED){
                stateHasRemoved(RemoveListPtr, EventCallHistoryListener::REMOVED);
index ef553af..2b6bb8a 100755 (executable)
@@ -117,32 +117,32 @@ void CallHistoryFilter::visitAttribute(std::string& attrName, MatchFlag& matchFl
        }
 
        if (attrName.compare(STR_DIRECTION) == 0) {
-               if (matchValue->toString().compare(STR_RECEIVED) == 0) {
+               if (matchValue->getString().compare(STR_RECEIVED) == 0) {
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING);
                        contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR);
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_INCOMMING);
                        contacts_filter_add_filter(filter, subFilter);
-               } else if (matchValue->toString().compare(STR_DIALED) == 0) {
+               } else if (matchValue->getString().compare(STR_DIALED) == 0) {
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_OUTGOING);
                        contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR);
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_OUTGOING);
                        contacts_filter_add_filter(filter, subFilter);
-               } else if (matchValue->toString().compare(STR_MISSED) == 0) {
+               } else if (matchValue->getString().compare(STR_MISSED) == 0) {
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING_SEEN);
                        contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR);
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_INCOMMING_SEEN);
                        contacts_filter_add_filter(filter, subFilter);
-               } else if (matchValue->toString().compare(STR_MISSED_NEW) == 0) {
+               } else if (matchValue->getString().compare(STR_MISSED_NEW) == 0) {
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN);
                        contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR);
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN);
                        contacts_filter_add_filter(filter, subFilter);
-               } else if (matchValue->toString().compare(STR_REJECTED) == 0) {
+               } else if (matchValue->getString().compare(STR_REJECTED) == 0) {
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_REJECT);
                        contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR);
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_REJECT);
                        contacts_filter_add_filter(filter, subFilter);
-               } else if (matchValue->toString().compare(STR_BLOCKED) == 0) {
+               } else if (matchValue->getString().compare(STR_BLOCKED) == 0) {
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_BLOCKED);
                        contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR);
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED);
@@ -151,12 +151,12 @@ void CallHistoryFilter::visitAttribute(std::string& attrName, MatchFlag& matchFl
                        contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_NONE);
                }
        } else if (attrName.compare(STR_TAGS) == 0) {
-               if (matchValue->toString().compare(STR_CALL) == 0) {
+               if (matchValue->getString().compare(STR_CALL) == 0) {
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING);
                        contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_AND);
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED);
                        contacts_filter_add_filter(filter, subFilter);
-               } else if (matchValue->toString().compare(STR_CALL_VOICE) == 0) {
+               } else if (matchValue->getString().compare(STR_CALL_VOICE) == 0) {
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING);
                        contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR);
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_OUTGOING);
@@ -169,7 +169,7 @@ void CallHistoryFilter::visitAttribute(std::string& attrName, MatchFlag& matchFl
                        contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR);
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VOICE_BLOCKED);
                        contacts_filter_add_filter(filter, subFilter);
-               } else if (matchValue->toString().compare(STR_CALL_VIDEO) == 0) {
+               } else if (matchValue->getString().compare(STR_CALL_VIDEO) == 0) {
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_INCOMMING);
                        contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR);
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_OUTGOING);
@@ -186,17 +186,17 @@ void CallHistoryFilter::visitAttribute(std::string& attrName, MatchFlag& matchFl
                        contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_NONE);
                }
        } else if (attrName.compare(STR_RP_REMOTEPARTY) == 0) {
-               contacts_filter_add_str(filter, _contacts_phone_log.address, mFlag, matchValue->toString().c_str());
+               contacts_filter_add_str(filter, _contacts_phone_log.address, mFlag, matchValue->getString().c_str());
        } else if (attrName.compare(STR_RP_PERSONID) == 0) {
-               contacts_filter_add_str(filter, _contacts_phone_log.person_id, mFlag, matchValue->toString().c_str());
+               contacts_filter_add_str(filter, _contacts_phone_log.person_id, mFlag, matchValue->getString().c_str());
        } else if (attrName.compare(STR_START_TIME) == 0) {
-               if(matchValue->getType() == PrimitiveType_Time) {
+               if(matchValue->isType(PrimitiveType_Time)) {
                        contacts_filter_add_int(filter, _contacts_phone_log.log_time, CONTACTS_MATCH_EQUAL, static_cast<int>(matchValue->getTimeT()));
                }
        } else if (attrName.compare(STR_DURATION) == 0) {
                contacts_filter_add_str(filter, _contacts_phone_log.extra_data1, mFlag, matchValue->toString().c_str());
        } else if (attrName.compare(STR_CALL_TYPE) == 0) {
-               if (matchValue->toString().compare(STR_TIZEN_TEL) == 0) {
+               if (matchValue->getString().compare(STR_TIZEN_TEL) == 0) {
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING);
                        contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_AND);
                        contacts_filter_add_int(subFilter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED);
@@ -205,7 +205,7 @@ void CallHistoryFilter::visitAttribute(std::string& attrName, MatchFlag& matchFl
                        contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_NONE);
                }
        } else if (attrName.compare(STR_ENTRY_ID) == 0) {
-               contacts_filter_add_str(filter, _contacts_phone_log.id, mFlag, matchValue->toString().c_str());
+               contacts_filter_add_str(filter, _contacts_phone_log.id, mFlag, matchValue->getString().c_str());
        } else {
                contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_EQUAL, CONTACTS_PLOG_TYPE_NONE);
        }
@@ -241,10 +241,10 @@ void CallHistoryFilter::visitAttributeRange(std::string& attrName, AnyPtr& initi
 
        if (!initialValue->isNullOrUndefined()) {
                if (propertyId != _contacts_phone_log.address) {
-                       if(initialValue->getType() == PrimitiveType_Time) {
+                       if(initialValue->isType(PrimitiveType_Time)) {
                                iValue = static_cast<int>(initialValue->getTimeT());
                        } else {
-                               iValue = atoi(initialValue->toString().c_str());
+                               iValue = atoi(initialValue->getString().c_str());
                        }
                }
                LogDebug("attrName [" << attrName << "] initialValue[" << initialValue->toString() << "] iValue[" << iValue << "]");
@@ -252,10 +252,10 @@ void CallHistoryFilter::visitAttributeRange(std::string& attrName, AnyPtr& initi
 
        if (!endValue->isNullOrUndefined()) {
                if (propertyId != _contacts_phone_log.address) {
-                       if(endValue->getType() == PrimitiveType_Time) {
+                       if(endValue->isType(PrimitiveType_Time)) {
                                eValue = static_cast<int>(endValue->getTimeT());
                        } else {
-                               eValue = atoi(endValue->toString().c_str());
+                               eValue = atoi(endValue->getString().c_str());
                        }
                }
                LogDebug("attrName [" << attrName << "] endValue[" << endValue->toString() << "] eValue[" << eValue << "]");
@@ -266,13 +266,13 @@ void CallHistoryFilter::visitAttributeRange(std::string& attrName, AnyPtr& initi
 
        if (propertyId == _contacts_phone_log.address) {
                if (!initialValue->isNullOrUndefined() && endValue->isNullOrUndefined()) {
-                       contacts_filter_add_str(filter, propertyId, CONTACTS_MATCH_STARTSWITH, initialValue->toString().c_str());
+                       contacts_filter_add_str(filter, propertyId, CONTACTS_MATCH_STARTSWITH, initialValue->getString().c_str());
                } else if (initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) {
-                       contacts_filter_add_str(filter, propertyId, CONTACTS_MATCH_ENDSWITH, endValue->toString().c_str());
+                       contacts_filter_add_str(filter, propertyId, CONTACTS_MATCH_ENDSWITH, endValue->getString().c_str());
                } else if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) {
-                       contacts_filter_add_str(subFilter, propertyId, CONTACTS_MATCH_STARTSWITH, initialValue->toString().c_str());
+                       contacts_filter_add_str(subFilter, propertyId, CONTACTS_MATCH_STARTSWITH, initialValue->getString().c_str());
                        contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_AND);
-                       contacts_filter_add_str(subFilter, propertyId, CONTACTS_MATCH_ENDSWITH, endValue->toString().c_str());
+                       contacts_filter_add_str(subFilter, propertyId, CONTACTS_MATCH_ENDSWITH, endValue->getString().c_str());
                        contacts_filter_add_filter(filter, subFilter);
                }
        } else {
diff --git a/src/Callhistory/CallHistoryFilterConverter.cpp b/src/Callhistory/CallHistoryFilterConverter.cpp
new file mode 100644 (file)
index 0000000..5271bf2
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file        CallHistoryFilterConverter.cpp
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @description        Reference from CalendarConverter.cpp
+ */
+
+#include "CallHistoryFilterConverter.h"
+
+#include <dpl/log/log.h>
+
+namespace DeviceAPI {
+namespace CallHistory {
+
+using namespace std;
+using namespace DeviceAPI::Tizen;
+
+static PropertyStructArray properties =
+{
+               { "uid",                        PrimitiveType_String},
+               { "type",                       PrimitiveType_String},
+               { "features",                   PrimitiveType_String},
+               { "remoteParties.remoteParty",  PrimitiveType_String},
+               { "remoteParties.personId",     PrimitiveType_String},
+               { "startTime",                  PrimitiveType_Time},
+               { "duration",                   PrimitiveType_String},
+               { "direction",                  PrimitiveType_String},
+               { 0,                            PrimitiveType_NoType}
+};
+
+CallHistoryFilterConverter::CallHistoryFilterConverter(JSContextRef context) :
+               FilterConverter(context, properties, false)
+{
+}
+
+CallHistoryFilterConverter::~CallHistoryFilterConverter()
+{
+       LogDebug("entered");
+}
+
+} // CallHistory
+} // DeviceAPI
+
diff --git a/src/Callhistory/CallHistoryFilterConverter.h b/src/Callhistory/CallHistoryFilterConverter.h
new file mode 100644 (file)
index 0000000..1d67e50
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file        CallHistoryFilterConverter.h
+ * @version     0.1
+ * @description        Reference from CalendarConverter.h
+ */
+
+#ifndef _TIZEN_CALLHISTORY_FILTER_CONVERTER_H_
+#define _TIZEN_CALLHISTORY_FILTER_CONVERTER_H_
+
+#include <set>
+#include <string>
+#include <FilterConverter.h>
+
+namespace DeviceAPI {
+namespace CallHistory {
+
+class CallHistoryFilterConverter : public DeviceAPI::Tizen::FilterConverter
+{
+public:
+       explicit CallHistoryFilterConverter(JSContextRef context);
+       virtual ~CallHistoryFilterConverter();
+};
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<CallHistoryFilterConverter> CallHistoryFilterConverterFactory;
+
+} // CallHistory
+} // DeviceAPI
+
+#endif // _TIZEN_CALLHISTORY_FILTER_CONVERTER_H_
+
index 7fb2d75..a67b29b 100755 (executable)
@@ -41,7 +41,7 @@
 #include "plugin_config.h"
 #include "CallHistoryAsyncCallbackManager.h"
 #include "CallHistoryListenerManager.h"
-
+#include "CallHistoryFilterConverter.h"
 
 
 using namespace std;
@@ -190,7 +190,8 @@ JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjec
 
                cbm->setObject(thisObject);
 
-               FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+               CallHistoryFilterConverterFactory::ConverterType filterConverter =
+                               CallHistoryFilterConverterFactory::getConverter(context);
 
                EventFindCallHistoryPtr event(new EventFindCallHistory());
                ICallHistoryPtr callHistory(priv->getObject());
old mode 100644 (file)
new mode 100755 (executable)
index 1b91a0e..4d59e03
@@ -12,6 +12,7 @@ SET(SRCS
   JSWebAPIErrorFactory.cpp
   JSWebAPIError2.cpp
   WebAPIError.cpp
+  PropertyBag.cpp
 )
 
 ADD_LIBRARY(${COMMON_TARGET_NAME} SHARED ${SRCS})
index f078178..89ae146 100755 (executable)
@@ -18,8 +18,8 @@
 #include "MultiCallbackUserData.h"
 #include "GlobalContextManager.h"
 #include "PlatformException.h"
-#include "Logger.h"
 #include "JSUtil.h"
+#include "Logger.h"
 
 using namespace std;
 
@@ -66,11 +66,11 @@ void MultiCallbackUserData::setCallback(const string &key, JSObjectRef callback)
     if( itr != mCallbacks.end() && itr->second != NULL){
         JSValueUnprotect(mContext, itr->second);
     }
-    
+
     if( callback != NULL ){
         JSValueProtect(mContext, callback);
     }
-    
+
     mCallbacks[key] = callback;
 }
 
@@ -121,7 +121,7 @@ void MultiCallbackUserData::invokeCallback(const std::string &key, int count, JS
         LOGE("There is no such callback[%s]", key.c_str());
         return;
     }
-    
+
     if( itr->second ){
         JSObjectCallAsFunction(mContext, itr->second , NULL, count, obj, NULL);
     }else{
index d71a2ca..2c578c5 100755 (executable)
@@ -21,6 +21,7 @@
 #include <JavaScriptCore/JavaScript.h>
 #include <string>
 #include <map>
+#include <boost/shared_ptr.hpp>
 
 namespace DeviceAPI {
 namespace Common{
@@ -36,7 +37,7 @@ class MultiCallbackUserData{
         void invokeCallback(const std::string &key);
         void invokeCallback(const std::string &key, JSValueRef obj);
         void invokeCallback(const std::string &key, int count, JSValueRef obj[]);
-       
+
     private:
         JSContextRef mContext;
         JSObjectRef mObject;
@@ -44,6 +45,8 @@ class MultiCallbackUserData{
         std::map<const std::string, JSObjectRef> mCallbacks;
 };
 
+typedef boost::shared_ptr<MultiCallbackUserData> MultiCallbackUserDataPtr;
+
 
 }
 }
diff --git a/src/Common/PropertyBag.cpp b/src/Common/PropertyBag.cpp
new file mode 100755 (executable)
index 0000000..2572745
--- /dev/null
@@ -0,0 +1,261 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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 "PropertyBag.h"
+#include "Logger.h"
+#include "JSUtil.h"
+#include "GlobalContextManager.h"
+#include "PlatformException.h"
+#include <cmath>
+
+using namespace std;
+
+namespace DeviceAPI {
+namespace Common {
+
+PropertyBag::PropertyBag(){
+}
+
+PropertyBag::~PropertyBag(){
+    contextMapT::iterator contextItr;
+    for( contextItr = mContextMap.begin() ; contextItr != mContextMap.end() ; ++contextItr){
+        propertyBagT::iterator propertyItr;
+        propertyBagT * bag = contextItr->second;
+        for( propertyItr = bag->begin(); propertyItr != bag->end(); ++propertyItr){
+            JSValueRef v = propertyItr->second;
+            if( v != NULL )
+                JSValueUnprotect(contextItr->first, v);
+        }
+        delete bag;
+    }
+}
+
+std::map<const std::string, JSValueRef> * PropertyBag::getBag(JSContextRef globalCtx){
+    //find property bag for the context
+    contextMapT::iterator itr;
+    itr = mContextMap.find(globalCtx);
+    propertyBagT *bag = NULL;
+
+    if( itr == mContextMap.end() ){
+        bag = new propertyBagT();
+        mContextMap[globalCtx] = bag;
+    }else{
+        bag = mContextMap[globalCtx];
+    }
+    return bag;
+}
+
+void PropertyBag::removeItem(JSContextRef globalCtx, propertyBagT *bag, const std::string& propertyName){
+    if( bag == NULL )
+        return;
+    propertyBagT::iterator item = bag->find(propertyName);
+    if( item != bag->end() && item->second != NULL){
+        JSValueUnprotect(globalCtx, item->second);
+        bag->erase(item);
+    }
+}
+
+void PropertyBag::deleteProperty(JSContextRef ctx, const std::string& propertyName){
+    JSContextRef globalCtx = GlobalContextManager::getInstance()->getGlobalContext(ctx);
+    if( globalCtx == NULL ){
+        LOGE("Cannot found global context!");
+        return;
+    }
+    propertyBagT *bag = getBag(globalCtx);
+    removeItem(globalCtx, bag, propertyName);
+}
+void PropertyBag::deleteProperty(JSContextRef ctx, JSStringRef propertyName){
+    deleteProperty(ctx, JSUtil::JSStringToString(ctx, propertyName));
+}
+
+
+bool PropertyBag::setProperty(JSContextRef ctx, const std::string& propertyName, JSValueRef value){
+    JSContextRef globalCtx = GlobalContextManager::getInstance()->getGlobalContext(ctx);
+    if( globalCtx == NULL ){
+        LOGE("Cannot found global context!");
+        return false;
+    }
+    propertyBagT *bag = getBag(globalCtx);
+    if( bag == NULL)
+        return false;
+    removeItem(globalCtx, bag, propertyName);
+    if( value != NULL )
+        JSValueProtect(globalCtx, value);
+    (*bag)[propertyName] = value;
+    return true;
+}
+
+bool PropertyBag::setProperty(JSContextRef ctx, const std::string& propertyName, double number){
+    JSValueRef value = JSUtil::toJSValueRef(ctx, number);
+    return setProperty(ctx, propertyName, value);
+}
+
+bool PropertyBag::setProperty(JSContextRef ctx, const std::string& propertyName, std::string& str){
+    JSValueRef value = JSUtil::toJSValueRef(ctx, str);
+    return setProperty(ctx, propertyName, value);
+}
+
+bool PropertyBag::setProperty(JSContextRef ctx, const std::string& propertyName, const char *str){
+    string strvalue = string(str);
+    JSValueRef value = JSUtil::toJSValueRef(ctx, strvalue);
+    return setProperty(ctx, propertyName, value);
+}
+
+bool PropertyBag::setProperty(JSContextRef ctx, const std::string& propertyName, bool boolean){
+    JSValueRef value = JSUtil::toJSValueRef(ctx, boolean);
+    return setProperty(ctx, propertyName, value);
+}
+
+
+bool PropertyBag::setProperty(JSContextRef ctx, const std::string& propertyName, JSValueRef value, JSClassRef classRef){
+    if( !JSValueIsObjectOfClass( ctx, value, classRef) ){
+        LOGE("The value is incorrect type");
+        return true;    //ignore set property
+    }
+    return setProperty(ctx, propertyName, value);
+}
+
+
+bool PropertyBag::setFunctionProperty(JSContextRef ctx, const std::string& propertyName, JSValueRef function){
+    JSObjectRef obj = JSUtil::JSValueToObject(ctx, function);
+    if( !JSObjectIsFunction( ctx, obj) ){
+        LOGE("The value is incorrect type");
+        return true;    //ignore set property
+    }
+    return setProperty(ctx, propertyName, function);
+}
+
+bool PropertyBag::setArrayProperty(JSContextRef ctx, const std::string& propertyName, JSValueRef array){
+    if( !JSIsArrayValue(ctx, array)){
+        LOGE("The value is not Array type");
+        return true;    //ignore set property
+    }
+    return setProperty(ctx, propertyName, array);
+}
+
+
+bool PropertyBag::setProperty(JSContextRef ctx, JSStringRef propertyName, JSValueRef value){
+    return setProperty(ctx, JSUtil::JSStringToString(ctx, propertyName), value);
+}
+bool PropertyBag::setProperty(JSContextRef ctx, JSStringRef propertyName, double number){
+    return setProperty(ctx, JSUtil::JSStringToString(ctx, propertyName), number);
+}
+bool PropertyBag::setProperty(JSContextRef ctx, JSStringRef propertyName, std::string& str){
+    return setProperty(ctx, JSUtil::JSStringToString(ctx, propertyName), str);
+}
+bool PropertyBag::setProperty(JSContextRef ctx, JSStringRef propertyName, const char * str){
+    return setProperty(ctx, JSUtil::JSStringToString(ctx, propertyName), str);
+}
+bool PropertyBag::setProperty(JSContextRef ctx, JSStringRef propertyName, bool boolean){
+    return setProperty(ctx, JSUtil::JSStringToString(ctx, propertyName), boolean);
+}
+bool PropertyBag::setProperty(JSContextRef ctx, JSStringRef propertyName, JSValueRef value, JSClassRef classRef){
+    return setProperty(ctx, JSUtil::JSStringToString(ctx, propertyName),value, classRef);
+}
+bool PropertyBag::setFunctionProperty(JSContextRef ctx, JSStringRef propertyName, JSValueRef function){
+    return setFunctionProperty(ctx, JSUtil::JSStringToString(ctx, propertyName),function);
+}
+bool PropertyBag::setArrayProperty(JSContextRef ctx, JSStringRef propertyName, JSValueRef array){
+    return setArrayProperty(ctx, JSUtil::JSStringToString(ctx, propertyName),array);
+}
+
+
+
+JSValueRef PropertyBag::getProperty(JSContextRef ctx, const std::string& propertyName){
+    JSContextRef globalCtx = GlobalContextManager::getInstance()->getGlobalContext(ctx);
+    if( globalCtx == NULL ){
+        LOGE("Cannot found global context!");
+        return NULL;
+    }
+
+    propertyBagT *bag = getBag(globalCtx);
+    if( bag == NULL)
+        return NULL;
+
+    propertyBagT::iterator item = bag->find(propertyName);
+    if( item == bag->end()){
+        LOGE("Cannot found item");
+        return NULL;
+    }
+    return item->second;
+}
+
+double PropertyBag::getNumberProperty(JSContextRef ctx, const std::string& propertyName){
+    JSValueRef value = getProperty(ctx, propertyName);
+    if( value == NULL )
+        return 0.0;
+    try{
+        return JSUtil::JSValueToDouble(ctx, value);
+    }catch(const BasePlatformException& err){
+        LOGE("Cannot convert to number");
+    }
+    return std::nan("not number");
+}
+
+double PropertyBag::getDoubleProperty(JSContextRef ctx, const std::string& propertyName){
+    JSValueRef value = getProperty(ctx, propertyName);
+    if( value == NULL )
+        return 0;
+    return JSUtil::JSValueToDouble(ctx, value);
+}
+
+bool PropertyBag::getBooleanProperty(JSContextRef ctx, const std::string& propertyName){
+    JSValueRef value = getProperty(ctx, propertyName);
+    if( value == NULL )
+        return false;
+    return JSUtil::JSValueToBoolean(ctx, value);
+}
+
+std::string PropertyBag::getStringProperty(JSContextRef ctx, const std::string& propertyName){
+    JSValueRef value = getProperty(ctx, propertyName);
+    if( value == NULL )
+        return "undefined";
+    return JSUtil::JSValueToString(ctx, value);
+}
+
+JSObjectRef PropertyBag::getObjectProperty(JSContextRef ctx, const std::string& propertyName){
+    JSValueRef value = getProperty(ctx, propertyName);
+    if( value == NULL )
+        return NULL;
+    if( !JSValueIsObject(ctx, value) )
+        return NULL;
+    return JSUtil::JSValueToObject(ctx, value);
+}
+
+double PropertyBag::getNumberProperty(JSContextRef ctx, JSStringRef propertyName){
+    return getNumberProperty(ctx, JSUtil::JSStringToString(ctx, propertyName));
+}
+double PropertyBag::getDoubleProperty(JSContextRef ctx, JSStringRef propertyName){
+    return getDoubleProperty(ctx, JSUtil::JSStringToString(ctx, propertyName));
+}
+bool PropertyBag::getBooleanProperty(JSContextRef ctx, JSStringRef propertyName){
+    return getBooleanProperty(ctx, JSUtil::JSStringToString(ctx, propertyName));
+}
+std::string PropertyBag::getStringProperty(JSContextRef ctx, JSStringRef propertyName){
+    return getStringProperty(ctx, JSUtil::JSStringToString(ctx, propertyName));
+}
+JSObjectRef PropertyBag::getObjectProperty(JSContextRef ctx, JSStringRef propertyName){
+    return getObjectProperty(ctx, JSUtil::JSStringToString(ctx, propertyName));
+}
+JSValueRef PropertyBag::getProperty(JSContextRef ctx, JSStringRef propertyName){
+    return getProperty(ctx, JSUtil::JSStringToString(ctx,propertyName));
+}
+
+
+
+} //Common
+} //DeviceAPI
diff --git a/src/Common/PropertyBag.h b/src/Common/PropertyBag.h
new file mode 100755 (executable)
index 0000000..71709da
--- /dev/null
@@ -0,0 +1,94 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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_COMMON_PROPERTY_BAG_H__
+#define __TIZEN_COMMON_PROPERTY_BAG_H__
+
+#include <JavaScriptCore/JavaScript.h>
+#include <string>
+#include <map>
+
+namespace DeviceAPI {
+namespace Common{
+
+class PropertyBag{
+public:
+    PropertyBag();
+    virtual ~PropertyBag();
+
+    void deleteProperty(JSContextRef ctx, const std::string& propertyName);
+    void deleteProperty(JSContextRef ctx, JSStringRef propertyName);
+
+
+    bool setProperty(JSContextRef ctx, const std::string& propertyName, JSValueRef value);
+    bool setProperty(JSContextRef ctx, JSStringRef propertyName, JSValueRef value);
+
+    bool setProperty(JSContextRef ctx, const std::string& propertyName, double number);
+    bool setProperty(JSContextRef ctx, JSStringRef propertyName, double number);
+
+    bool setProperty(JSContextRef ctx, const std::string& propertyName, std::string& str);
+    bool setProperty(JSContextRef ctx, JSStringRef propertyName, std::string& str);
+
+    bool setProperty(JSContextRef ctx, const std::string& propertyName, const char *str);
+    bool setProperty(JSContextRef ctx, JSStringRef propertyName, const char * str);
+
+    bool setProperty(JSContextRef ctx, const std::string& propertyName, bool boolean);
+    bool setProperty(JSContextRef ctx, JSStringRef propertyName, bool boolean);
+
+    bool setProperty(JSContextRef ctx, const std::string& propertyName, JSValueRef value, JSClassRef classRef);
+    bool setProperty(JSContextRef ctx, JSStringRef propertyName, JSValueRef value, JSClassRef classRef);
+
+    bool setFunctionProperty(JSContextRef ctx, const std::string& propertyName, JSValueRef function);
+    bool setFunctionProperty(JSContextRef ctx, JSStringRef propertyName, JSValueRef function);
+
+    bool setArrayProperty(JSContextRef ctx, const std::string& propertyName, JSValueRef array);
+    bool setArrayProperty(JSContextRef ctx, JSStringRef propertyName, JSValueRef array);
+
+    JSValueRef getProperty(JSContextRef ctx, const std::string& propertyName);
+    JSValueRef getProperty(JSContextRef ctx, JSStringRef propertyName);
+
+    double getNumberProperty(JSContextRef ctx, const std::string& propertyName);
+    double getNumberProperty(JSContextRef ctx, JSStringRef propertyName);
+
+    double getDoubleProperty(JSContextRef ctx, const std::string& propertyName);
+    double getDoubleProperty(JSContextRef ctx, JSStringRef propertyName);
+
+    bool getBooleanProperty(JSContextRef ctx, const std::string& propertyName);
+    bool getBooleanProperty(JSContextRef ctx, JSStringRef propertyName);
+
+    std::string getStringProperty(JSContextRef ctx, const std::string& propertyName);
+    std::string getStringProperty(JSContextRef ctx, JSStringRef propertyName);
+
+    JSObjectRef getObjectProperty(JSContextRef ctx, const std::string& propertyName);
+    JSObjectRef getObjectProperty(JSContextRef ctx, JSStringRef propertyName);
+
+private:
+    typedef std::map<const std::string, JSValueRef> propertyBagT;
+    typedef std::map<JSContextRef, propertyBagT*> contextMapT;
+    std::map<JSContextRef, propertyBagT*> mContextMap;
+
+    std::map<const std::string, JSValueRef> * getBag(JSContextRef globalCtx);
+    void removeItem(JSContextRef globalCtx, propertyBagT *bag, const std::string& propertyName);
+
+};
+
+
+} //Common
+} //DeviceAPI
+
+
+#endif //__TIZEN_COMMON_PROPERTY_BAG_H__
diff --git a/src/Common/TimeTracer/CMakeLists.txt b/src/Common/TimeTracer/CMakeLists.txt
new file mode 100644 (file)
index 0000000..73e451c
--- /dev/null
@@ -0,0 +1,22 @@
+SET(TARGET "timetracer")
+
+SET(SRCS
+  TimeTracer.c
+)
+
+INCLUDE_DIRECTORIES(
+       ${TOP}/Common
+)
+
+ADD_LIBRARY(${TARGET} SHARED ${SRCS})
+
+TARGET_LINK_LIBRARIES(${TARGET}
+  ${LIBS_COMMON}
+)
+
+INSTALL(TARGETS ${TARGET} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${COMMON_DESTINATION_NAME})
+INSTALL(
+        DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/common
+        FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE
+)
+
diff --git a/src/Common/TimeTracer/TimeTracer.c b/src/Common/TimeTracer/TimeTracer.c
new file mode 100644 (file)
index 0000000..ba64207
--- /dev/null
@@ -0,0 +1,352 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+#undef LOG_TAG
+#define LOG_TAG "TIME_TRACER"
+
+#include <stdio.h>
+#include <dlog.h>
+#include <stdio.h>
+#include <malloc.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/time.h>
+#include <sys/utsname.h>
+#include <sys/resource.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <time.h>
+#include "TimeTracer.h"
+
+/*
+* Global Variables
+*/
+#undef TIME_TRACER_UNIT_MSEC
+#define TIME_TRACER_ITEM_MAX   100
+#define OUTPUT_FILE "/tmp/wrt-plugins-tizen-time-trace-result.log"
+
+time_tracer_item ** g_items = NULL; //Time tracer item list
+static int g_index = 0;
+static int g_max_item_name_length = 0;
+static unsigned long g_first_time = 0xFFFFFFFF;
+
+/*
+* Internal Implementation
+*/
+static void __time_tracer_item_free(void)
+{
+       int i = 0;
+       if (!g_items)
+               return;
+
+       for(i=0;i<g_index;i++)
+       {
+               if(g_items[i])
+               {
+                       if (g_items[i]->name)
+                               free(g_items[i]->name);
+                       free(g_items[i]);
+                       g_items[i] = NULL;
+               }
+       }
+
+       g_index = 0;
+       g_max_item_name_length = 0;
+       g_first_time = 0xFFFFFFFF;
+       free(g_items);
+       g_items = NULL;
+}
+
+static int __get_time_tracer_item_index(char* name)
+{
+       int i;
+       assert(name);
+       if(!g_items)
+               return -1;
+
+       for ( i = 0; i < g_index; i++ )
+       {
+               if(!g_items[i])
+                       return -1;
+               if (strcmp(name, g_items[i]->name)==0)
+                       return i;
+       }
+       return -1;
+}
+
+
+/*
+* Implementation
+*/
+int time_tracer_init(void)
+{
+       g_items = (time_tracer_item **) malloc(TIME_TRACER_ITEM_MAX * sizeof(time_tracer_item *));
+       if(!g_items)
+       {
+               LOGE("[%s] Failed to create global tracer item",__FUNCTION__);
+               return -1;
+       }
+       g_first_time = 0xFFFFFFFF;
+       return 0;
+}
+
+int time_tracer_release(void)
+{
+       if (!g_items)
+               return 0;
+       __time_tracer_item_free();
+       return 0;
+}
+
+int time_tracer_item_begin(const char* name, int show, const char* filename, int line)
+{
+       time_tracer_item *item = NULL;
+       int index = 0;
+       int name_len = 0;
+       struct timeval t;
+
+       if (!g_items)
+               return 0;
+
+       if (g_index == TIME_TRACER_ITEM_MAX)
+       {
+               LOGE("[%s] Do not exceed tracer item max value (max : %d, index : %d)",__FUNCTION__,TIME_TRACER_ITEM_MAX, g_index);
+               return -1;
+       }
+
+       if (!name)
+       {
+               LOGE("[%s] Item name is NULL.",__FUNCTION__);
+               return -1;
+       }
+
+       name_len = strlen(name);
+       if(name_len==0)
+       {
+               LOGE("[%s] Item name is Empty.",__FUNCTION__);
+               return -1;
+       }
+
+       //1. Creates of gets the item
+       //1-1. Creates new item if 'name' is not exists.
+       if ((index = __get_time_tracer_item_index(name)) == -1)
+       {
+               item = (time_tracer_item *)malloc(sizeof(time_tracer_item));
+               if ( !item )
+               {
+                       LOGE("[%s] Failed to create tracer item", __FUNCTION__);
+                       return -1;
+               }
+
+               //Clean-up
+               memset( item, 0, sizeof (time_tracer_item) );
+               item->min_elapsed_time = 0xFFFFFFFF;
+
+               item->name = strdup(name);
+               if (!item->name)
+               {
+                       LOGE("[%s] Failed to strdup", __FUNCTION__);
+                       free(item);
+                       return -1;
+               }
+
+               //Add to the global item array
+               g_items[g_index] = item;
+               g_index++;
+
+               if ( g_max_item_name_length < name_len )
+                       g_max_item_name_length = name_len;
+       }
+       else // 1-2. Returns existing item
+       {
+               item = g_items[index];
+       }
+
+       // 2. Verify pairs of begin, end
+       if (item->on_tracing)
+       {
+               LOGE("[%s] (Name : %s) is not 'end'ed!",__FUNCTION__, item->name);
+               item->mismatch_count ++;
+               return -1;
+       }
+
+       // 3. Gets the timestamp
+       gettimeofday( &t, NULL );
+       item->timestamp = t.tv_sec*1000000L + t.tv_usec;
+#ifdef TIME_TRACER_UNIT_MSEC
+       item->timestamp = ( item->timestamp >= 1000) ? item->timestamp/1000 : 0;
+#endif
+
+       //set tracing on
+       item->on_tracing = 1;
+       if (item->first_timestamp == 0) // in case of first
+       {
+               //set first timestamp
+               item->first_timestamp = item->timestamp;
+               if (g_first_time > item->first_timestamp)
+                       g_first_time = item->first_timestamp;
+       }
+       if (show)
+       {
+               LOGE("[%s][BEGIN] %s (at %s:%d)", __FUNCTION__,name, filename, line );
+           printf("[%s][BEGIN] %s (at %s:%d)\n", LOG_TAG,name, filename, line );
+       }
+       //Add invoke count for given item
+       item->invoke_count++;
+       return 0;
+}
+
+int time_tracer_item_end(const char* name, int show, const char* filename, int line)
+{
+       time_tracer_item * item = NULL;
+       unsigned int tval = 0;
+       int index = 0;
+       struct timeval t;
+
+       if (!g_items)
+               return 0;
+
+       // 1. Gets current timestamp first for more accuracy.
+       gettimeofday( &t, NULL );
+
+       if (g_index == TIME_TRACER_ITEM_MAX)
+       {
+               LOGE("[%s] Do not exceed tracer item max value (max : %d, index : %d)",__FUNCTION__,TIME_TRACER_ITEM_MAX, g_index);
+               return -1;
+       }
+
+       if (!name)
+       {
+               LOGE("[%s] Item name is NULL.",__FUNCTION__);
+               return -1;
+       }
+
+       if(strlen(name)==0)
+       {
+               LOGE("[%s] Item name is Empty.",__FUNCTION__);
+               return -1;
+       }
+
+       //2. Gets the item
+       if ((index = __get_time_tracer_item_index(name)) == -1)
+       {
+               LOGE("[%s] (Name : %s) is not exist.",__FUNCTION__, name);
+               return -1;
+       }
+       item = g_items[index];
+
+       // 3. Verify pairs of begin, end
+       if (!item->on_tracing)
+       {
+               LOGE("[%s] (Name : %s) is not 'begin' yet",__FUNCTION__, item->name);
+               item->mismatch_count ++;
+               return -1;
+       }
+
+       tval = t.tv_sec*1000000L + t.tv_usec;
+#ifdef TIME_TRACER_UNIT_MSEC
+       tval = (tval>=1000) ? tval/1000 : 0;
+#endif
+
+       //set last timestamp as current time
+       item->last_timestamp = tval;
+
+       //calculates the time gap(elapsed time) between current timestamp and item's timestamp.
+       tval = tval - item->timestamp;
+
+       //set max_elapsed_time if current elapsed time is larger than item's max elasped time.
+       item->max_elapsed_time = tval > item->max_elapsed_time ? tval : item->max_elapsed_time;
+       //set min_elapsed_time if current elapsed time is less than item's min elasped time.
+       item->min_elapsed_time = tval < item->min_elapsed_time ? tval : item->min_elapsed_time;
+
+       //Accumulates the item's total elapse time
+       item->total_elapsed_time += tval;
+       //set tracing off
+       item->on_tracing = 0;
+
+       if (show)
+       {
+               LOGE("[%s][END] %s - total elapsed time(acc): %ld, current elased time : %d (at %s:%d)",__FUNCTION__, name, item->total_elapsed_time, tval, filename, line );
+               printf("[%s][END] %s - total elapsed time(acc): %ld, current elased time : %d (at %s:%d)\n",LOG_TAG,name, item->total_elapsed_time, tval, filename, line );
+       }
+       return 0;
+}
+
+void time_tracer_export_report(int direction)
+{
+       int i = 0;
+       char format[256];
+       FILE* fp = stderr;
+
+       if (!g_items)
+               return;
+
+       switch (direction)
+       {
+               case TIME_TRACER_EXPORT_STDOUT:
+                       fp = stdout;
+                       break;
+               case TIME_TRACER_EXPORT_STDERR:
+                       fp = stderr;
+                       break;
+               case TIME_TRACER_EXPORT_FILE:
+                       fp = fopen(OUTPUT_FILE, "wt");
+                       if (!fp)
+                       {
+                               LOGE("[%s] Failed to fopen().",__FUNCTION__);
+                               return;
+                       }
+                       break;
+               default:
+                       LOGE("[%s] Invalid output direction.",__FUNCTION__);
+                       return;
+       }
+
+#ifdef TIME_TRACER_UNIT_MSEC
+       sprintf(format, "[%%3d] %%-%ds|\tTotal:%%4ld,\tCnt:%%3ld,\tAvg:%%4ld,\tMin:%%4ld,\tMax:%%4ld,\tStart:%%4lu,\tEnd:%%4lu,\tMismatch:%%3ld\n", g_max_item_name_length);
+       fprintf(fp, "TIME TRACER REPORT [BEGIN]=========================== [# of Item:%d, unit(msec)]\n", g_index);
+       //sprintf(format, "[%%3d] %%-%ds | \tTotal : %%4ld\t# of calls : %%3ld\tAvg : %%4ld\tMin : %%4ld\tMax : %%4ld\tStart : %%4lu\tEnd : %%4lu\t# of Mismatch : %%3ld\n", g_max_item_name_length);
+       //fprintf(fp, "TIME TRACER REPORT [BEGIN]=========================== : # of Item : %d, unit(msec)\n", g_index);
+#else
+       snprintf(format, sizeof(format)-1, "[%%3d] %%-%ds |\tTotal:%%ld,\tCnt:%%ld,\tAvg:%%ld,\tMin:%%ld,\tMax:%%ld,\tStart:%%lu,\tEnd:%%lu,\tMismatch:%%ld\n", g_max_item_name_length);
+       fprintf(fp, "TIME TRACER REPORT [BEGIN]=========================== [# of Item:%d, unit(usec)]\n", g_index);
+       //snprintf(format, sizeof(format)-1, "[%%3d] %%-%ds | \tTotal : %%ld\t# of calls : %%ld\tAvg : %%ld\tMin : %%ld\tMax : %%ld\tStart : %%lu\tEnd : %%lu\t# of Mismatch : %%ld\n", g_max_item_name_length);
+       //fprintf(fp, "TIME TRACER REPORT [BEGIN]============================ : # of Item : %d, unit(usec)\n", g_index);
+#endif
+
+       for ( i = 0; i < g_index; i++ )
+       {
+               if (g_items[i]->invoke_count == 0)
+                       g_items[i]->invoke_count = 1;
+
+               fprintf(fp,format,i,
+                       g_items[i]->name, // item name
+                       g_items[i]->total_elapsed_time, // total elasped time
+                       g_items[i]->invoke_count, // # of call
+                       (g_items[i]->total_elapsed_time == 0)?0:(int)(g_items[i]->total_elapsed_time / g_items[i]->invoke_count), // calculates the average elapsed time
+                       g_items[i]->min_elapsed_time, // mininum elpased time
+                       g_items[i]->max_elapsed_time,// maximum elpased time
+                       g_items[i]->first_timestamp - g_first_time, //begin timestamp
+                       g_items[i]->last_timestamp - g_first_time, //end timestamp
+                       g_items[i]->mismatch_count ); // # of mismatch (begin - end mismatch)
+       }
+       fprintf(fp, "TIME TRACER REPORT [END]  ============================\n");
+
+       if ( direction == TIME_TRACER_EXPORT_FILE )
+               fclose(fp);
+}
diff --git a/src/Common/TimeTracer/TimeTracer.h b/src/Common/TimeTracer/TimeTracer.h
new file mode 100644 (file)
index 0000000..e5b49e0
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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_COMMON_TIME_TRACER__
+#define __TIZEN_COMMON_TIME_TRACER__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _time_tracer_item
+{
+       char* name;
+       unsigned long total_elapsed_time;
+       unsigned long min_elapsed_time;
+       unsigned long max_elapsed_time;
+       unsigned long first_timestamp;
+       unsigned long last_timestamp;
+       unsigned long timestamp;
+       int on_tracing;
+       int invoke_count;
+       int mismatch_count;
+} time_tracer_item;
+
+/* COMMON */
+int time_tracer_init(void);
+int time_tracer_release(void);
+void time_tracer_export_report(int direction);
+int time_tracer_item_begin(const char* name, int show,const  char* filename, int line);
+int time_tracer_item_end(const char* name, int show, const char* filename, int line);
+
+#define TIME_TRACER_EXPORT_STDOUT      0
+#define TIME_TRACER_EXPORT_STDERR      1
+#define TIME_TRACER_EXPORT_FILE        2
+
+#ifdef ENABLE_TIME_TRACER
+//Initialize the time tracer
+#define TIME_TRACER_INIT()     (time_tracer_init())
+//Release the time tracer
+#define TIME_TRACER_RELEASE()  (time_tracer_release())
+//Export tracing report to stdout
+#define TIME_TRACER_EXPORT_REPORT()            (time_tracer_export_report(TIME_TRACER_EXPORT_STDOUT))
+//Export tracing report to user specific direction (stdout, stderr, file)
+#define TIME_TRACER_EXPORT_REPORT_TO(x)        (time_tracer_export_report(x))
+//Set tracing point to begin
+#define TIME_TRACER_ITEM_BEGIN(name,show)      (time_tracer_item_begin(name,show,__FILE__,__LINE__))
+//Set tracing point to end
+#define TIME_TRACER_ITEM_END(name,show)        (time_tracer_item_end(name,show,__FILE__,__LINE__)      )
+#else
+#define TIME_TRACER_INIT()
+#define TIME_TRACER_RELEASE()
+#define TIME_TRACER_EXPORT_REPORT()
+#define TIME_TRACER_EXPORT_REPORT_TO(x)
+#define TIME_TRACER_ITEM_BEGIN(name,show)
+#define TIME_TRACER_ITEM_END(name,show)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__TIZEN_COMMON_TIME_TRACER__
index 52cc741..4e4f9d0 100755 (executable)
@@ -14,7 +14,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
 )
 
@@ -42,6 +41,7 @@ SET(SRCS_IMPL
        ContactObjectP2AConverter.cpp
        ContactsSvcObjectConverter.cpp
        ContactSearchEngine.cpp
+       ContactFilterConverter.cpp
        ContactFilterValidator.cpp
        ContactsSvcChangeListenerManager.cpp
        ContactsSvcWrapper.cpp
index c1ed5cc..8b2f24a 100755 (executable)
@@ -1079,6 +1079,10 @@ ContactAddressPtr ContactConverter::toContactAddressFromInit(const JSValueRef &j
        if (!validator.isNullOrUndefined(typesData)) {
                types = toContactAddressTypeArray(typesData);
                result->setTypes(types);
+       }else{
+               ContactAddressTypeArrayPtr typeArray(new ContactAddressTypeArray());
+               typeArray->push_back(CONTACT_ADDRESS_TYPE_HOME);
+               result->setTypes(typeArray);
        }
 
        return result;
@@ -1319,6 +1323,12 @@ JSValueRef ContactConverter::toJSValueRef(const ContactAddressTypeArrayPtr &arg)
                        ThrowMsg(ConversionException, "Can not add object to array.");
        }
 
+       if(size == 0){
+               JSValueRef jsvalue = toJSValueRef(CONTACT_ADDRESS_TYPE_HOME);
+               if (!JSSetArrayElement(m_context, resultObject, 0, jsvalue))
+                       ThrowMsg(ConversionException, "Can not add object to array.");
+       }
+
        return static_cast<JSValueRef>(resultObject);
 }
 
diff --git a/src/Contact/ContactFilterConverter.cpp b/src/Contact/ContactFilterConverter.cpp
new file mode 100644 (file)
index 0000000..82ed8db
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file        ContactFilterConverter.cpp
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @description        Reference from CalendarConverter.cpp
+ */
+
+#include "ContactFilterConverter.h"
+
+#include <dpl/log/log.h>
+
+namespace DeviceAPI {
+namespace Contact {
+
+using namespace std;
+using namespace DeviceAPI::Tizen;
+
+static PropertyStructArray propertiesContact =
+{
+               { "id",                         PrimitiveType_String },
+               { "personId",                   PrimitiveType_String },
+               { "addressBookId",              PrimitiveType_String },
+               { "lastUpdated",                PrimitiveType_Time },
+               { "isFavorite",                 PrimitiveType_Boolean },
+               { "name.prefix",                PrimitiveType_String },
+               { "name.suffix",                PrimitiveType_String },
+               { "name.firstName",             PrimitiveType_String },
+               { "name.middleName",            PrimitiveType_String },
+               { "name.lastName",              PrimitiveType_String },
+               { "name.nicknames",             PrimitiveType_String },
+               { "name.phoneticFirstName",     PrimitiveType_String },
+               { "name.phoneticLastName",      PrimitiveType_String },
+               { "name.displayName",           PrimitiveType_String },
+               { "addresses.country",          PrimitiveType_String },
+               { "addresses.region",           PrimitiveType_String },
+               { "addresses.city",             PrimitiveType_String },
+               { "addresses.streetAddress",    PrimitiveType_String },
+               { "addresses.additionalInformation",    PrimitiveType_String },
+               { "addresses.postalCode",       PrimitiveType_String },
+               { "addresses.isDefault",        PrimitiveType_Boolean },
+               { "addresses.types",            PrimitiveType_String },
+               { "photoURI",                   PrimitiveType_String },
+               { "phoneNumbers.number",        PrimitiveType_String },
+               { "phoneNumbers.isDefault",     PrimitiveType_Boolean },
+               { "phoneNumbers.types",         PrimitiveType_String },
+               { "emails.email",               PrimitiveType_String },
+               { "emails.isDefault",           PrimitiveType_Boolean },
+               { "emails.types",               PrimitiveType_String },
+               { "birthday",                   PrimitiveType_Time },
+               { "anniversaries.date",         PrimitiveType_Time },
+               { "anniversaries.label",        PrimitiveType_String },
+               { "organizations.name",         PrimitiveType_String },
+               { "organizations.department",   PrimitiveType_String },
+               { "organizations.title",        PrimitiveType_String },
+               { "organizations.role",         PrimitiveType_String },
+               { "organizations.logoURI",      PrimitiveType_String },
+               { "notes",                      PrimitiveType_String },
+               { "urls.url",                   PrimitiveType_String },
+               { "urls.type",                  PrimitiveType_String },
+               { "ringtoneURI",                PrimitiveType_String },
+               { "groupIds",                   PrimitiveType_String },
+               { 0,                            PrimitiveType_NoType }
+};
+
+static PropertyStructArray propertiesPerson =
+{
+               { "id",                         PrimitiveType_String },
+               { "displayName",                PrimitiveType_String },
+               { "contactCount",               PrimitiveType_Long },
+               { "hasPhoneNumber",             PrimitiveType_Boolean },
+               { "hasEmail",                   PrimitiveType_Boolean },
+               { "isFavorite",                 PrimitiveType_Boolean },
+               { "photoURI",                   PrimitiveType_String },
+               { "ringtoneURI",                PrimitiveType_String },
+               { "displayContactId",           PrimitiveType_String },
+               { 0,                            PrimitiveType_NoType }
+};
+
+ContactFilterConverter::ContactFilterConverter(JSContextRef context) :
+               FilterConverter(context, propertiesContact, false)
+{
+}
+
+ContactFilterConverter::~ContactFilterConverter()
+{
+       LogDebug("entered");
+}
+
+PersonFilterConverter::PersonFilterConverter(JSContextRef context) :
+               FilterConverter(context, propertiesPerson, false)
+{
+}
+
+PersonFilterConverter::~PersonFilterConverter()
+{
+       LogDebug("entered");
+}
+
+} // Contact
+} // DeviceAPI
+
diff --git a/src/Contact/ContactFilterConverter.h b/src/Contact/ContactFilterConverter.h
new file mode 100644 (file)
index 0000000..4564a5e
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file        ContactFilterConverter.h
+ * @version     0.1
+ * @description        Reference from ContactFilterConverter.h
+ */
+
+#ifndef _TIZEN_CONTACT_FILTER_CONVERTER_H_
+#define _TIZEN_CONTACT_FILTER_CONVERTER_H_
+
+#include <set>
+#include <string>
+#include <FilterConverter.h>
+
+namespace DeviceAPI {
+namespace Contact {
+
+class ContactFilterConverter : public DeviceAPI::Tizen::FilterConverter
+{
+public:
+       explicit ContactFilterConverter(JSContextRef context);
+       virtual ~ContactFilterConverter();
+};
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<ContactFilterConverter> ContactFilterConverterFactory;
+
+class PersonFilterConverter : public DeviceAPI::Tizen::FilterConverter
+{
+public:
+       explicit PersonFilterConverter(JSContextRef context);
+       virtual ~PersonFilterConverter();
+};
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<PersonFilterConverter> PersonFilterConverterFactory;
+
+} // Contact
+} // DeviceAPI
+
+#endif // _TIZEN_CONTACT_FILTER_CONVERTER_H_
+
index abb4387..beb1390 100755 (executable)
@@ -342,7 +342,7 @@ void ContactSearchEngine::visitAttribute(string& attrName, MatchFlag& matchFlag,
                if(attrName == "id")
                        value = ContactUtility::strToInt(matchValue->getString());
                else
-                       value = matchValue->getInt();
+                       value = matchValue->getLong();
 
                contacts_match_int_flag_e flag;
                if(matchFlag == MATCH_EXISTS)
@@ -468,9 +468,9 @@ void ContactSearchEngine::visitAttributeRange(string& attrName, AnyPtr& initialV
                else
                {
                        if(initialValueIsSet)
-                               initialValueInt = initialValue->getInt();
+                               initialValueInt = initialValue->getLong();
                        if(endValueIsSet)
-                               endValueInt = endValue->getInt();
+                               endValueInt = endValue->getLong();
                }
 
                queryAttributeRangeInt(properties, idSet, initialValueIsSet, initialValueInt, endValueIsSet, endValueInt);
index c00f48c..f74e15b 100755 (executable)
@@ -48,6 +48,9 @@
 #include "JSAddressBookChangeCallbackManager.h"
 #include "ContactAsyncCallbackManager.h"
 #include "ContactListenerManager.h"
+#include "ContactFilterConverter.h"
+#include <ArgumentValidator.h>
+#include <JSWebAPIError.h>
 
 using namespace std;
 
@@ -62,7 +65,8 @@ namespace DeviceAPI {
 namespace Contact {
 
 using namespace DeviceAPI::Common;
-using namespace DeviceAPI::Tizen;\rusing namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Tizen;
+using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 
 JSClassRef JSAddressBook::m_jsClassRef = NULL;
@@ -88,10 +92,10 @@ JSClassDefinition JSAddressBook::m_classInfo = {
 };
 
 JSStaticValue JSAddressBook::m_property[] = {
-       { TIZEN_ADDRESS_BOOK_ID, getId, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_ADDRESS_BOOK_NAME, getName, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_ADDRESS_BOOK_READ_ONLY, getReadOnly, NULL, kJSPropertyAttributeReadOnly },
-//     { TIZEN_ADDRESS_BOOK_ACCOUNT_ID, getAccountId, NULL, kJSPropertyAttributeReadOnly },
+       { TIZEN_ADDRESS_BOOK_ID, getId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_ADDRESS_BOOK_NAME, getName, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_ADDRESS_BOOK_READ_ONLY, getReadOnly, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+//     { TIZEN_ADDRESS_BOOK_ACCOUNT_ID, getAccountId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { 0, 0, 0, 0 }
 };
 
@@ -288,21 +292,19 @@ JSValueRef JSAddressBook::get(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_GET);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-
-       if (argumentCount < 1) {
-               /* 1st Argument must be string. */
-               LogError("1st argument must not be undefined.");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "No Contact id 'undefined'");
-       }
-
        string id;
 
-       ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
-       Try     {
-               id = converter->toString(arguments[0]);
-       } Catch(Exception) {
-               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+       try     {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               id = validator.toString(0, false);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        EventAddressBookGetPtr dplEvent(new EventAddressBookGet());
@@ -337,8 +339,9 @@ JSValueRef JSAddressBook::get(JSContextRef context,
                }
        }
 
-       ContactPtr contact = dplEvent->getContact();
+       ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
 
+       ContactPtr contact = dplEvent->getContact();
        JSValueRef result;
        Try {
                result = converter->toJSValueRef(contact);
@@ -377,22 +380,25 @@ JSValueRef JSAddressBook::add(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       Try {
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument is an 'undefined'.");
-
-               if (!JSContact::isObjectOfClass(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not a 'Contact object'.");
-
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'Contact object'");
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               validator.toObject(0, false);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        ContactPtr contact(NULL);
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
        Try     {
+               if (!JSContact::isObjectOfClass(context, arguments[0]))
+                       ThrowMsg(InvalidArgumentException, "1st argument is not a 'Contact object'.");
                contact = converter->toContact(arguments[0]);
        } Catch(Exception) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
@@ -460,42 +466,26 @@ JSValueRef JSAddressBook::addBatch(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_BATCH);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               // check 1st argument
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact object'");
-
-               if (!JSValueIsObject(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact object'");
-
-               // check 2nd argument
-               if(argumentCount >= 2)
-               {
-                       if(validator->isCallback(arguments[1]))
-                               js2ndParamIsFunction = true;
-
-                       if (!js2ndParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[1]) &&
-                                       !JSValueIsUndefined(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument must be a 'function' or a 'null'");
-               }
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
 
-               // check 3rd argument
-               if(argumentCount >= 3)
-               {
-                       if(validator->isCallback(arguments[2]))
-                               js3rdParamIsFunction = true;
+               validator.toObject(0, false);
+               JSObjectRef successObj = validator.toFunction(1, true);
+               if(successObj)
+                       js2ndParamIsFunction = true;
 
-                       if (!js3rdParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[2]) &&
-                                       !JSValueIsUndefined(context, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "3rd argument must be a 'function' or a 'null'");
-               }
+               JSObjectRef errorObj = validator.toFunction(2, true);
+               if(errorObj)
+                       js3rdParamIsFunction = true;
 
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
@@ -564,22 +554,26 @@ JSValueRef JSAddressBook::update(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       Try {
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument is an 'undefined'.");
-
-               if (!JSContact::isObjectOfClass(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not a 'Contact object'.");
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               validator.toObject(0, false);
 
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'Contact object'");
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        ContactPtr contact(NULL);
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
        Try     {
+               if (!JSContact::isObjectOfClass(context, arguments[0]))
+                       ThrowMsg(InvalidArgumentException, "1st argument is not a 'Contact object'.");
                contact = converter->toContact(arguments[0]);
        } Catch(Exception) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
@@ -650,42 +644,27 @@ JSValueRef JSAddressBook::updateBatch(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE_BATCH);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               // check 1st argument
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact object'");
-
-               if (!JSValueIsObject(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact object'");
-
-               // check 2nd argument
-               if(argumentCount >= 2)
-               {
-                       if(validator->isCallback(arguments[1]))
-                               js2ndParamIsFunction = true;
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
 
-                       if (!js2ndParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[1]) &&
-                                       !JSValueIsUndefined(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument must be a 'function' or a 'null'");
-               }
+               validator.toObject(0, false);
 
-               // check 3rd argument
-               if(argumentCount >= 3)
-               {
-                       if(validator->isCallback(arguments[2]))
-                               js3rdParamIsFunction = true;
+               JSObjectRef successObj = validator.toFunction(1, true);
+               if(successObj)
+                       js2ndParamIsFunction = true;
 
-                       if (!js3rdParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[2]) &&
-                                       !JSValueIsUndefined(context, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "3rd argument must be a 'function' or a 'null'");
-               }
+               JSObjectRef errorObj = validator.toFunction(2, true);
+               if(errorObj)
+                       js3rdParamIsFunction = true;
 
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
@@ -754,21 +733,18 @@ JSValueRef JSAddressBook::remove(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount < 1) {
-               /* 1st Argument must be string. */
-               LogError("1st argument must not be undefined.");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "No Contact id 'undefined'");
-       }
-
+       ArgumentValidator validator(context, argumentCount, arguments);
        string contactId;
-
-       ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
-       Try     {
-               contactId = converter->toString(arguments[0]);
-       }
-       Catch(Exception) {
-               LogError("Error on conversion " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments.");
+       try     {
+               contactId = validator.toString(0, false);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        EventAddressBookRemovePtr dplEvent(new EventAddressBookRemove());
@@ -836,42 +812,26 @@ JSValueRef JSAddressBook::removeBatch(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_BATCH);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               // check 1st argument
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact id'");
-
-               if (!JSValueIsObject(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact id'");
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
 
-               // check 2nd argument
-               if(argumentCount >= 2)
-               {
-                       if(validator->isCallback(arguments[1]))
-                               js2ndParamIsFunction = true;
+               validator.toObject(0, false);
+               JSObjectRef successObj = validator.toFunction(1, true);
+               if(successObj)
+                       js2ndParamIsFunction = true;
 
-                       if (!js2ndParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[1]) &&
-                                       !JSValueIsUndefined(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument must be a 'function' or a 'null'");
-               }
+               JSObjectRef errorObj = validator.toFunction(2, true);
+               if(errorObj)
+                       js3rdParamIsFunction = true;
 
-               // check 3rd argument
-               if(argumentCount >= 3)
-               {
-                       if(validator->isCallback(arguments[2]))
-                               js3rdParamIsFunction = true;
-
-                       if (!js3rdParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[2]) &&
-                                       !JSValueIsUndefined(context, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "3rd argument must be a 'function' or a 'null'");
-               }
-
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
@@ -944,49 +904,30 @@ JSValueRef JSAddressBook::find(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_FIND);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'function'");
-
-               if (!validator->isCallback(arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'function'");
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
 
-               if (argumentCount >= 2)
-               {
-                       if(validator->isCallback(arguments[1]))
-                               js2ndParamIsFunction = true;
-
-                       if (!js2ndParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[1]) &&
-                                       !JSValueIsUndefined(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "1st argument must be a 'function' or a 'null'");
-               }
-
-               if (argumentCount >= 3)
-               {
-                       if(JSValueIsObject(context, arguments[2]))
-                               js3rdParamIsObject = true;
+               validator.toFunction(0, false);
+               JSObjectRef errorObj = validator.toFunction(1, true);
+               if(errorObj)
+                       js2ndParamIsFunction = true;
 
-                       if (!js3rdParamIsObject &&
-                                       !JSValueIsNull(context, arguments[2]) &&
-                                       !JSValueIsUndefined(context, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "3rd argument must be an 'Filter object' or 'null'");
-               }
+               JSObjectRef filterObj = validator.toObject(2, true);
+               if(filterObj)
+                       js3rdParamIsObject = true;
 
-               if (argumentCount >= 4)
-               {
-                       if(JSValueIsObject(context, arguments[3]))
-                               js4thParamIsObject = true;
+               JSObjectRef sortObj = validator.toObject(3, true);
+               if(sortObj)
+                       js4thParamIsObject = true;
 
-                       if (!js4thParamIsObject &&
-                                       !JSValueIsNull(context, arguments[3]) &&
-                                       !JSValueIsUndefined(context, arguments[3]))
-                               ThrowMsg(InvalidArgumentException, "4th argument must be an 'SortMode object' or 'null'");
-               }
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
@@ -999,7 +940,7 @@ JSValueRef JSAddressBook::find(JSContextRef context,
        callbackManager->setObject(thisObject);
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
-       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+       ContactFilterConverterFactory::ConverterType filterConverter = ContactFilterConverterFactory::getConverter(context);
 
        EventAddressBookFindPtr dplEvent(new EventAddressBookFind());
        Try {
@@ -1067,27 +1008,20 @@ JSValueRef JSAddressBook::addChangeListener(JSContextRef context,
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'AddressBookChangeCallback object'");
-
-               if (!JSValueIsObject(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'AddressBookChangeCallback object'");
-
-               if (argumentCount >= 2)
-               {
-                       if(validator->isCallback(arguments[1]))
-                               js2ndParamIsFunction = true;
-
-                       if (!js2ndParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[1]) &&
-                                       !JSValueIsUndefined(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument must be a 'function' or a 'null'");
-               }
-
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+       try {
+               ArgumentValidator Argvalidator(context, argumentCount, arguments);
+               Argvalidator.toObject(0, false);
+               JSObjectRef errorObj = Argvalidator.toFunction(1, true);
+               if(errorObj)
+                       js2ndParamIsFunction = true;
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
@@ -1210,24 +1144,19 @@ JSValueRef JSAddressBook::removeChangeListener(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_CHANGE_LISTENER);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       if (argumentCount < 1)
-       {
-               LogError("1st argument must not be undefined.");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "No watch id 'undefined'");
-       }
-
-       ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
-
        long watchId = 0;
-       Try {
-               watchId = static_cast<long>(converter->toLong(arguments[0]));
 
-               if (watchId < 0)
-                       ThrowMsg(PlatformException, "watchId is wrong (" << watchId << ")");
-       } Catch(Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               watchId = validator.toLong(0, false, 0);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        EventAddressBookRemoveChangeListenerPtr dplEvent(new EventAddressBookRemoveChangeListener());
@@ -1284,29 +1213,26 @@ JSValueRef JSAddressBook::getGroup(JSContextRef context,
                gContext = controller->getContext();
        } Catch(Exception) {
                LogError("No private object");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_GET_GROUP);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount < 1) {
-               /* 1st Argument must be string. */
-               LogError("1st argument must not be undefined.");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::NOT_FOUND_ERROR, "No Group id 'undefined'");
-       }
-
        string id;
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
-       Try     {
-               id = converter->toString(arguments[0]);
-       } Catch(Exception) {
-               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+       try     {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               id = validator.toString(0, false);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        EventAddressBookGetGroupPtr dplEvent(new EventAddressBookGetGroup());
@@ -1387,23 +1313,27 @@ JSValueRef JSAddressBook::addGroup(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_GROUP);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       Try {
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument is an 'undefined'.");
-
-               if (!JSContactGroup::isObjectOfClass(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not a 'ContactGroup object'.");
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               validator.toObject(0, false);
 
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'ContactGroup object'");
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        ContactGroupPtr group(NULL);
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
        Try     {
+               if (!JSContactGroup::isObjectOfClass(context, arguments[0]))
+                       ThrowMsg(InvalidArgumentException, "1st argument is not a 'ContactGroup object'.");
+
                group = converter->toContactGroup(arguments[0]);
        } Catch(Exception) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
@@ -1463,35 +1393,36 @@ JSValueRef JSAddressBook::updateGroup(JSContextRef context,
                gContext = controller->getContext();
        } Catch(Exception) {
                LogError("No private object");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE_GROUP);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       Try {
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument is an 'undefined'.");
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               validator.toObject(0, false);
 
-               if (!JSContactGroup::isObjectOfClass(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not a 'ContactGroup object'.");
-
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'ContactGroup object'");
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        ContactGroupPtr contact(NULL);
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
        Try     {
+               if (!JSContactGroup::isObjectOfClass(context, arguments[0]))
+                       ThrowMsg(InvalidArgumentException, "1st argument is not a 'ContactGroup object'.");
                contact = converter->toContactGroup(arguments[0]);
        } Catch(Exception) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "1st argument is not a 'ContactGroup object'");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument is not a 'ContactGroup object'");
        }
 
        EventAddressBookUpdateGroupPtr dplEvent(new EventAddressBookUpdateGroup());
@@ -1560,23 +1491,19 @@ JSValueRef JSAddressBook::removeGroup(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_GROUP);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount < 1) {
-               /* 1st Argument must be string. */
-               LogError("1st argument must not be undefined.");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::NOT_FOUND_ERROR, "No ContactGroup id 'undefined'");
-       }
-
        string groupId;
 
-       ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
-       Try     {
-               groupId = converter->toString(arguments[0]);
-       }
-       Catch(Exception) {
-               LogError("Error on conversion " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments.");
+       try     {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               groupId = validator.toString(0, false);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        EventAddressBookRemoveGroupPtr dplEvent(new EventAddressBookRemoveGroup());
index 806fb58..41aff4e 100755 (executable)
@@ -33,6 +33,8 @@
 #include "ContactConverter.h"
 #include "JSContact.h"
 #include "Contact.h"
+#include <ArgumentValidator.h>
+#include <JSWebAPIError.h>
 
 #define FILTER_CLASS_NAME "Contact"
 
@@ -86,11 +88,11 @@ JSClassDefinition JSContact::m_classInfo =
 };
 
 JSStaticValue JSContact::m_property[] = {
-       { CONTACT_ATTR_ID, getId, NULL, kJSPropertyAttributeReadOnly },
-       { CONTACT_ATTR_ADDRESSBOOK_ID, getAddressBookId, NULL, kJSPropertyAttributeReadOnly },
-       { CONTACT_ATTR_PERSON_ID, getPersonId, NULL, kJSPropertyAttributeReadOnly },
-       { CONTACT_ATTR_LAST_UPDATED, getLastUpdated, NULL, kJSPropertyAttributeReadOnly },
-       { CONTACT_ATTR_IS_FAVORITE, getIsFavorite, NULL, kJSPropertyAttributeReadOnly },
+       { CONTACT_ATTR_ID, getId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete},
+       { CONTACT_ATTR_ADDRESSBOOK_ID, getAddressBookId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete},
+       { CONTACT_ATTR_PERSON_ID, getPersonId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete},
+       { CONTACT_ATTR_LAST_UPDATED, getLastUpdated, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { CONTACT_ATTR_IS_FAVORITE, getIsFavorite, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { CONTACT_ATTR_NAME, getName, setName, kJSPropertyAttributeNone },
        { CONTACT_ATTR_ADDRESSES, getAddresses, setAddresses, kJSPropertyAttributeNone },
        { CONTACT_ATTR_PHOTO_URI, getPhotoURI, setPhotoURI, kJSPropertyAttributeNone },
@@ -457,15 +459,14 @@ bool JSContact::setName(JSContextRef context,
                        contact->unsetName();
                else
                        contact->setName(converter->toContactName(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContact::getAddresses(JSContextRef context,
@@ -519,15 +520,14 @@ bool JSContact::setAddresses(JSContextRef context,
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
                contact->setAddresses(converter->toContactAddressArray(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContact::getPhotoURI(JSContextRef context,
@@ -570,15 +570,14 @@ bool JSContact::setPhotoURI(JSContextRef context,
                        contact->unsetPhotoURI();
                else
                        contact->setPhotoURI(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContact::getPhoneNumbers(JSContextRef context,
@@ -633,15 +632,14 @@ bool JSContact::setPhoneNumbers(JSContextRef context,
                                ContactConverterFactory::getConverter(context);
                contact->setPhoneNumbers(
                                converter->toContactPhoneNumberArray(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContact::getEmails(JSContextRef context,
@@ -698,15 +696,14 @@ bool JSContact::setEmails(JSContextRef context,
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
                contact->setEmails(converter->toContactEmailAddressArray(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContact::getBirthday(JSContextRef context,
@@ -749,15 +746,14 @@ bool JSContact::setBirthday(JSContextRef context,
                        contact->unsetBirthday();
                else
                        contact->setBirthday(converter->toDateTm(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContact::getAnniversaries(JSContextRef context,
@@ -811,17 +807,15 @@ bool JSContact::setAnniversaries(JSContextRef context,
                ContactPtr contact = getPrivData(object);
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
-               contact->setAnniversaries(
-                               converter->toContactAnniversaryArray(value));
-               return true;
+               contact->setAnniversaries(converter->toContactAnniversaryArray(value));
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContact::getOrganizations(JSContextRef context,
@@ -875,17 +869,15 @@ bool JSContact::setOrganizations(JSContextRef context,
                ContactPtr contact = getPrivData(object);
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
-               contact->setOrganizations(
-                               converter->toContactOrganizationArray(value));
-               return true;
+               contact->setOrganizations(converter->toContactOrganizationArray(value));
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContact::getNotes(JSContextRef context,
@@ -940,15 +932,14 @@ bool JSContact::setNotes(JSContextRef context,
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
                contact->setNotes(converter->toStringArray(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContact::getUrls(JSContextRef context,
@@ -1003,15 +994,14 @@ bool JSContact::setUrls(JSContextRef context,
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
                contact->setUrls(converter->toContactWebSiteArray(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContact::getRingtoneURI(JSContextRef context,
@@ -1054,15 +1044,14 @@ bool JSContact::setRingtoneURI(JSContextRef context,
                        contact->unsetRingtoneURI();
                else
                        contact->setRingtoneURI(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContact::getGroupIds(JSContextRef context,
@@ -1118,15 +1107,14 @@ bool JSContact::setGroupIds(JSContextRef context,
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
                contact->setGroupIds(converter->toStringArray(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContact::convertToString(JSContextRef context,
@@ -1153,27 +1141,18 @@ JSValueRef JSContact::convertToString(JSContextRef context,
 //     CONTACT_FUNCTION_API_CONVERT_TO_STRING);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               if (argumentCount >= 1 &&
-                               ( !JSValueIsUndefined(context, arguments[0] ) &&
-                               ( !JSValueIsNull(context, arguments[0]) ) &&
-                               ( !JSValueIsString(context, arguments[0] )) ))
-                       ThrowMsg(ConversionException, "1st argument must be 'ContactTextFormat string'");
-       } Catch (Exception) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactTextFormat string'");
-       }
-
+       ArgumentValidator validator(context, argumentCount, arguments);
        std::string format;
-
-       ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
-       Try     {
-               if(argumentCount >= 1)
-                       format = converter->toString(arguments[0]);
-       } Catch(Exception) {
-               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactTextFormat string'");
+       try     {
+               format = validator.toString(0, false);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        std::string vCard;
@@ -1190,6 +1169,7 @@ JSValueRef JSContact::convertToString(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
+       ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
        JSValueRef result;
        Try {
                result = converter->toJSValueRef(vCard);
index d59fc32..55ba72d 100755 (executable)
@@ -271,14 +271,13 @@ bool JSContactAddress::setCountry(JSContextRef context,
                        contactAddress->unsetCountry();
                else
                        contactAddress->setCountry(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 
@@ -321,14 +320,13 @@ bool JSContactAddress::setRegion(JSContextRef context,
                        contactAddress->unsetRegion();
                else
                        contactAddress->setRegion(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactAddress::getCity(JSContextRef context,
@@ -370,14 +368,13 @@ bool JSContactAddress::setCity(JSContextRef context,
                        contactAddress->unsetCity();
                else
                        contactAddress->setCity(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 
@@ -420,14 +417,13 @@ bool JSContactAddress::setStreetAddress(JSContextRef context,
                        contactAddress->unsetStreetAddress();
                else
                        contactAddress->setStreetAddress(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 
@@ -470,14 +466,13 @@ bool JSContactAddress::setAdditionalInformation(JSContextRef context,
                        contactAddress->unsetAdditionalInformation();
                else
                        contactAddress->setAdditionalInformation(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 
@@ -520,14 +515,13 @@ bool JSContactAddress::setPostalCode(JSContextRef context,
                        contactAddress->unsetPostalCode();
                else
                        contactAddress->setPostalCode(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 
@@ -564,14 +558,13 @@ bool JSContactAddress::setIsDefault(JSContextRef context,
                BasicValidator validator =
                                BasicValidatorFactory::getValidator(context, exception);
                contactAddress->setIsDefault(converter->toBool(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 
@@ -625,15 +618,13 @@ bool JSContactAddress::setTypes(JSContextRef context,
                                ContactConverterFactory::getConverter(context);
 
                contactAddress->setTypes(converter->toContactAddressTypeArray(value));
-
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 } // Contact
index daaf1c8..5f73b0e 100755 (executable)
@@ -263,14 +263,13 @@ bool JSContactAnniversary::setDate(JSContextRef context,
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
                anniversary->setDate(converter->toDateTm(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactAnniversary::getLabel(JSContextRef context,
@@ -312,14 +311,13 @@ bool JSContactAnniversary::setLabel(JSContextRef context,
                        anniversary->unsetLabel();
                else
                        anniversary->setLabel(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 } // Contact
index af4fc69..8c8daf0 100755 (executable)
@@ -210,6 +210,9 @@ JSObjectRef JSContactEmailAddress::constructor(JSContextRef context,
                else
                        types = ContactEmailAddressTypeArrayPtr(new ContactEmailAddressTypeArray());
 
+               if(types->size() == 0)
+                       types->push_back(CONTACT_EMAIL_TYPE_WORK);
+
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
@@ -285,14 +288,13 @@ bool JSContactEmailAddress::setEmail(JSContextRef context,
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
                emailAddress->setEmail(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 
@@ -329,14 +331,13 @@ bool JSContactEmailAddress::setIsDefault(JSContextRef context,
                BasicValidator validator =
                                BasicValidatorFactory::getValidator(context, exception);
                emailAddress->setIsDefault(converter->toBool(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 
@@ -394,15 +395,13 @@ bool JSContactEmailAddress::setTypes(JSContextRef context,
                        emailAddress->setTypes(JSContactEmailAddressTypeArray::getContactEmailAddressTypeArray(context, value));
                else
                        emailAddress->setTypes(converter->toContactEmailAddressTypeArray(value));
-
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 } // Contact
index e66a38e..cb8c7ee 100755 (executable)
@@ -68,12 +68,12 @@ JSClassDefinition JSContactGroup::m_classInfo =
 };
 
 JSStaticValue JSContactGroup::m_property[] = {
-       { CONTACT_PROP_ATTR_ID, getId, NULL, kJSPropertyAttributeReadOnly },
-       { CONTACT_PROP_ATTR_ADDRESSBOOK_ID, getAddressBookId, NULL, kJSPropertyAttributeReadOnly },
+       { CONTACT_PROP_ATTR_ID, getId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { CONTACT_PROP_ATTR_ADDRESSBOOK_ID, getAddressBookId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { CONTACT_PROP_ATTR_NAME, getName, setName, kJSPropertyAttributeNone },
        { CONTACT_PROP_ATTR_RINGTONE_URI, getRingtoneURI, setRingtoneURI, kJSPropertyAttributeNone },
        { CONTACT_PROP_ATTR_PHOTO_URI, getPhotoURI, setPhotoURI, kJSPropertyAttributeNone },
-       { CONTACT_PROP_ATTR_READ_ONLY, getReadOnly, NULL, kJSPropertyAttributeReadOnly },
+       { CONTACT_PROP_ATTR_READ_ONLY, getReadOnly, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { 0, 0, 0, 0 }
 };
 
@@ -311,15 +311,14 @@ bool JSContactGroup::setAddressBookId(JSContextRef context,
                        contactGroup->unsetAddressBookId();
                else
                        contactGroup->setAddressBookId(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactGroup::getName(JSContextRef context,
@@ -362,15 +361,14 @@ bool JSContactGroup::setName(JSContextRef context,
                        contactGroup->unsetName();
                else
                        contactGroup->setName(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactGroup::getRingtoneURI(JSContextRef context,
@@ -413,15 +411,14 @@ bool JSContactGroup::setRingtoneURI(JSContextRef context,
                        contactGroup->unsetRingtoneURI();
                else
                        contactGroup->setRingtoneURI(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactGroup::getPhotoURI(JSContextRef context,
@@ -464,15 +461,14 @@ bool JSContactGroup::setPhotoURI(JSContextRef context,
                        contactGroup->unsetRingtoneURI();
                else
                        contactGroup->setPhotoURI(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactGroup::getReadOnly(JSContextRef context,
index 97d775b..61ad0db 100755 (executable)
@@ -44,6 +44,9 @@
 #include "ContactConverter.h"
 #include "JSPerson.h"
 #include "JSContactManagerChangeCallbackManager.h"
+#include "ContactFilterConverter.h"
+#include <ArgumentValidator.h>
+#include <JSWebAPIError.h>
 
 namespace DeviceAPI {
 namespace Contact {
@@ -157,27 +160,20 @@ JSValueRef JSContactManager::getAddressBooks(JSContextRef context,
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'function'");
-
-               if (!validator->isCallback(arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'function'");
-
-               if (argumentCount >= 2)
-               {
-                       if (validator->isCallback(arguments[1]))
-                               js2ndParamIsFunction = true;
-
-                       if (!js2ndParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[1]) &&
-                                       !JSValueIsUndefined(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2st argument must be a 'function' or a 'null");
-               }
-
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               validator.toFunction(0, false);
+               JSObjectRef errorObj = validator.toFunction(1, true);
+               if(errorObj)
+                       js2ndParamIsFunction = true;
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
@@ -386,21 +382,20 @@ JSValueRef JSContactManager::getAddressBook(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       if (argumentCount < 1) {
-               /* 1st Argument must be string. */
-               LogError("1st argument must not be undefined.");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "No AddressBook name 'undefined'");
-       }
-
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
 
        std::string addressBookId;
-       Try {
-               addressBookId = converter->toString(arguments[0]);
-       }
-       Catch(Exception) {
-               LogError("Error on conversion " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong argument");
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               addressBookId = validator.toString(0, false);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        EventContactManagerGetAddressBookPtr dplEvent(new EventContactManagerGetAddressBook());
@@ -482,11 +477,17 @@ JSValueRef JSContactManager::get(JSContextRef context,
        std::string id;
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
-       Try     {
-               id = converter->toString(arguments[0]);
-       } Catch(Exception) {
-               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+       try     {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               id = validator.toString(0, false);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        EventContactManagerGetPtr dplEvent(new EventContactManagerGet());
@@ -559,22 +560,25 @@ JSValueRef JSContactManager::update(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_UPDATE);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       Try {
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument is an 'undefined'.");
-
-               if (!JSPerson::isObjectOfClass(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not a 'Contact object'.");
-
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'Contact object'");
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               validator.toObject(0, false);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        PersonPtr person(NULL);
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
        Try     {
+               if (!JSPerson::isObjectOfClass(context, arguments[0]))
+                       ThrowMsg(InvalidArgumentException, "1st argument is not a 'Contact object'.");
                person = converter->toPerson(arguments[0]);
        } Catch(Exception) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
@@ -646,43 +650,25 @@ JSValueRef JSContactManager::updateBatch(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_UPDATE_BATCH);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               // check 1st argument
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact object'");
-
-               if (!JSValueIsObject(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact object'");
-
-               // check 2nd argument
-               if(argumentCount >= 2)
-               {
-                       if(validator->isCallback(arguments[1]))
-                               js2ndParamIsFunction = true;
-
-                       if (!js2ndParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[1]) &&
-                                       !JSValueIsUndefined(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument must be a 'function' or a 'null'");
-               }
-
-               // check 3rd argument
-               if(argumentCount >= 3)
-               {
-                       if(validator->isCallback(arguments[2]))
-                               js3rdParamIsFunction = true;
-
-                       if (!js3rdParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[2]) &&
-                                       !JSValueIsUndefined(context, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "3rd argument must be a 'function' or a 'null'");
-               }
-
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
+
+               validator.toObject(0, false);
+               JSObjectRef successObj = validator.toFunction(1, true);
+               if(successObj)
+                       js2ndParamIsFunction = true;
+
+               JSObjectRef errorObj = validator.toFunction(2, true);
+               if(errorObj)
+                       js3rdParamIsFunction = true;
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
@@ -751,23 +737,20 @@ JSValueRef JSContactManager::remove(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount < 1) {
-               /* 1st Argument must be string. */
-               LogError("1st argument must not be undefined.");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::NOT_FOUND_ERROR, "No Contact id 'undefined'");
-       }
-
        std::string personId;
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
-       Try     {
-               personId = converter->toString(arguments[0]);
-       }
-       Catch(Exception) {
-               LogError("Error on conversion " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments.");
+       try     {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               personId = validator.toString(0, false);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        EventContactManagerRemovePtr dplEvent(new EventContactManagerRemove());
@@ -839,42 +822,25 @@ JSValueRef JSContactManager::removeBatch(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE_BATCH);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               // check 1st argument
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact id'");
-
-               if (!JSValueIsObject(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact id'");
-
-               // check 2nd argument
-               if(argumentCount >= 2)
-               {
-                       if(validator->isCallback(arguments[1]))
-                               js2ndParamIsFunction = true;
-
-                       if (!js2ndParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[1]) &&
-                                       !JSValueIsUndefined(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument must be a 'function' or a 'null'");
-               }
-
-               // check 3rd argument
-               if(argumentCount >= 3)
-               {
-                       if(validator->isCallback(arguments[2]))
-                               js3rdParamIsFunction = true;
-
-                       if (!js3rdParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[2]) &&
-                                       !JSValueIsUndefined(context, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "3rd argument must be a 'function' or a 'null'");
-               }
-
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
+
+               validator.toObject(0, false);
+               JSObjectRef successObj = validator.toFunction(1, true);
+               if(successObj)
+                       js2ndParamIsFunction = true;
+
+               JSObjectRef errorObj = validator.toFunction(2, true);
+               if(errorObj)
+                       js3rdParamIsFunction = true;
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
@@ -947,49 +913,30 @@ JSValueRef JSContactManager::find(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_FIND);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'function'");
-
-               if (!validator->isCallback(arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'function'");
-
-               if (argumentCount >= 2)
-               {
-                       if(validator->isCallback(arguments[1]))
-                               js2ndParamIsFunction = true;
-
-                       if (!js2ndParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[1]) &&
-                                       !JSValueIsUndefined(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "1st argument must be a 'function' or a 'null'");
-               }
-
-               if (argumentCount >= 3)
-               {
-                       if(JSValueIsObject(context, arguments[2]))
-                               js3rdParamIsObject = true;
-
-                       if (!js3rdParamIsObject &&
-                                       !JSValueIsNull(context, arguments[2]) &&
-                                       !JSValueIsUndefined(context, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "3rd argument must be an 'Filter object' or 'null'");
-               }
-
-               if (argumentCount >= 4)
-               {
-                       if(JSValueIsObject(context, arguments[3]))
-                               js4thParamIsObject = true;
-
-                       if (!js4thParamIsObject &&
-                                       !JSValueIsNull(context, arguments[3]) &&
-                                       !JSValueIsUndefined(context, arguments[3]))
-                               ThrowMsg(InvalidArgumentException, "4th argument must be an 'SortMode object' or 'null'");
-               }
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
+
+               validator.toFunction(0, false);
+               JSObjectRef errorObj = validator.toFunction(1, true);
+               if(errorObj)
+                       js2ndParamIsFunction = true;
+
+               JSObjectRef filterObj = validator.toObject(2, true);
+               if(filterObj)
+                       js3rdParamIsObject = true;
+
+               JSObjectRef sortObj = validator.toObject(3, true);
+               if(sortObj)
+                       js4thParamIsObject = true;
+
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
@@ -1002,7 +949,7 @@ JSValueRef JSContactManager::find(JSContextRef context,
        callbackManager->setObject(thisObject);
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
-       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+       PersonFilterConverterFactory::ConverterType filterConverter = PersonFilterConverterFactory::getConverter(context);
 
        EventContactManagerFindPtr dplEvent(new EventContactManagerFind());
        Try {
@@ -1070,27 +1017,22 @@ JSValueRef JSContactManager::addChangeListener(JSContextRef context,
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               if (argumentCount < 1)
-                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'ContactManagerChangeCallback object'");
-
-               if (!JSValueIsObject(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'ContactManagerChangeCallback object'");
-
-               if (argumentCount >= 2)
-               {
-                       if(validator->isCallback(arguments[1]))
-                               js2ndParamIsFunction = true;
-
-                       if (!js2ndParamIsFunction &&
-                                       !JSValueIsNull(context, arguments[1]) &&
-                                       !JSValueIsUndefined(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument must be a 'function' or a 'null'");
-               }
-
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+       try {
+               ArgumentValidator Argvalidator(context, argumentCount, arguments);
+
+               Argvalidator.toObject(0, false);
+               JSObjectRef errorObj = Argvalidator.toFunction(1, true);
+               if(errorObj)
+                       js2ndParamIsFunction = true;
+
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
@@ -1213,24 +1155,20 @@ JSValueRef JSContactManager::removeChangeListener(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE_CHANGE_LISTENER);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       if (argumentCount < 1)
-       {
-               LogError("1st argument must not be undefined.");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "No watch id 'undefined'");
-       }
-
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
 
        long watchId = 0;
-       Try {
-               watchId = static_cast<long>(converter->toLong(arguments[0]));
-
-               if (watchId < 0)
-                       ThrowMsg(PlatformException, "watchId is wrong (" << watchId << ")");
-       } Catch(Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+       try {
+               ArgumentValidator validator(context, argumentCount, arguments);
+               watchId = validator.toLong(0, false, 0);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        EventContactManagerRemoveChangeListenerPtr dplEvent(new EventContactManagerRemoveChangeListener());
index 6ac722b..b56c561 100755 (executable)
@@ -80,7 +80,7 @@ JSStaticValue JSContactName::m_property[] = {
        { CONTACT_PROP_ATTR_PHONETIC_NAME, getPhoneticName, setPhoneticName, kJSPropertyAttributeNone },
        { CONTACT_PROP_ATTR_PHONETIC_FIRST_NAME, getPhoneticFirstName, setPhoneticFirstName, kJSPropertyAttributeNone },
        { CONTACT_PROP_ATTR_PHONETIC_LAST_NAME, getPhoneticLastName, setPhoneticLastName, kJSPropertyAttributeNone },
-       { CONTACT_PROP_ATTR_DISPLAY_NAME, getDisplayName, NULL, kJSPropertyAttributeReadOnly },
+       { CONTACT_PROP_ATTR_DISPLAY_NAME, getDisplayName, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { 0, 0, 0, 0 }
 };
 
@@ -281,15 +281,13 @@ bool JSContactName::setPrefix(JSContextRef context,
                        contactName->unsetPrefix();
                else
                        contactName->setPrefix(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactName::getSuffix(JSContextRef context,
@@ -326,21 +324,18 @@ bool JSContactName::setSuffix(JSContextRef context,
                ContactNamePtr contactName = getPrivData(object);
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
-               BasicValidator validator =
-                               BasicValidatorFactory::getValidator(context, exception);
+               BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
                if(validator->isNullOrUndefined(value))
                        contactName->unsetSuffix();
                else
                        contactName->setSuffix(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactName::getFirstName(JSContextRef context,
@@ -375,23 +370,20 @@ bool JSContactName::setFirstName(JSContextRef context,
        Try
        {
                ContactNamePtr contactName = getPrivData(object);
-               ContactConverterFactory::ConverterType converter =
-                               ContactConverterFactory::getConverter(context);
-               BasicValidator validator =
-                               BasicValidatorFactory::getValidator(context, exception);
+               ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
+               BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
                if(validator->isNullOrUndefined(value))
                        contactName->unsetFirstName();
                else
                        contactName->setFirstName(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactName::getMiddleName(JSContextRef context,
@@ -434,15 +426,14 @@ bool JSContactName::setMiddleName(JSContextRef context,
                        contactName->unsetMiddleName();
                else
                        contactName->setMiddleName(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactName::getLastName(JSContextRef context,
@@ -485,15 +476,14 @@ bool JSContactName::setLastName(JSContextRef context,
                        contactName->unsetLastName();
                else
                        contactName->setLastName(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactName::getNicknames(JSContextRef context,
@@ -547,15 +537,14 @@ bool JSContactName::setNicknames(JSContextRef context,
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
                contactName->setNicknames(converter->toStringArray(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactName::getPhoneticName(JSContextRef context,
@@ -617,15 +606,14 @@ bool JSContactName::setPhoneticFirstName(JSContextRef context,
                        contactName->unsetPhoneticFirstName();
                else
                        contactName->setPhoneticFirstName(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactName::getPhoneticLastName(JSContextRef context,
@@ -668,15 +656,14 @@ bool JSContactName::setPhoneticLastName(JSContextRef context,
                        contactName->unsetPhoneticLastName();
                else
                        contactName->setPhoneticLastName(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactName::getDisplayName(JSContextRef context,
index 822091d..ee2252c 100755 (executable)
@@ -265,14 +265,13 @@ bool JSContactOrganization::setName(JSContextRef context,
                        organization->unsetName();
                else
                        organization->setName(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 
@@ -315,14 +314,13 @@ bool JSContactOrganization::setDepartment(JSContextRef context,
                        organization->unsetDepartment();
                else
                        organization->setDepartment(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactOrganization::getOffice(JSContextRef context,
@@ -383,14 +381,13 @@ bool JSContactOrganization::setTitle(JSContextRef context,
                        organization->unsetTitle();
                else
                        organization->setTitle(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactOrganization::getRole(JSContextRef context,
@@ -432,14 +429,13 @@ bool JSContactOrganization::setRole(JSContextRef context,
                        organization->unsetRole();
                else
                        organization->setRole(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 JSValueRef JSContactOrganization::getLogoURI(JSContextRef context,
@@ -481,14 +477,13 @@ bool JSContactOrganization::setLogoURI(JSContextRef context,
                        organization->unsetLogoURI();
                else
                        organization->setLogoURI(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 } // Contact
index a1b4b27..c0501f9 100755 (executable)
@@ -288,14 +288,13 @@ bool JSContactPhoneNumber::setNumber(JSContextRef context,
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
                contactPhoneNumber->setNumber(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 
@@ -332,14 +331,13 @@ bool JSContactPhoneNumber::setIsDefault(JSContextRef context,
                BasicValidator validator =
                                BasicValidatorFactory::getValidator(context, exception);
                contactPhoneNumber->setIsDefault(converter->toBool(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 
@@ -389,19 +387,16 @@ bool JSContactPhoneNumber::setTypes(JSContextRef context,
        Try
        {
                ContactPhoneNumberPtr contactPhoneNumber = getPrivData(object);
-               ContactConverterFactory::ConverterType converter =
-                               ContactConverterFactory::getConverter(context);
+               ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
 
                contactPhoneNumber->setTypes(converter->toContactPhoneNumberTypeArray(value));
-
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 } // Contact
index a684baf..10a81d9 100755 (executable)
@@ -197,6 +197,8 @@ JSObjectRef JSContactWebSite::constructor(JSContextRef context,
        Try {
                if (js2ndParamIsString)
                        type = converter->toContactWebSiteType(arguments[1]);
+               else
+                       type = WEBSITE_TYPE_HOMEPAGE;
 
        } Catch(Exception) {
                LogError("2nd argument only support 'HOMEPAGE' or 'BLOG'");
@@ -204,8 +206,7 @@ JSObjectRef JSContactWebSite::constructor(JSContextRef context,
 
        ContactWebSitePtr contactWebSite(new ContactWebSite());
        contactWebSite->setUrl(url);
-       if(js2ndParamIsString)
-               contactWebSite->setType(type);
+       contactWebSite->setType(type);
 
        JSObjectRef jsobject;
 
@@ -259,14 +260,13 @@ bool JSContactWebSite::setUrl(JSContextRef context,
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
                webSite->setUrl(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 
@@ -313,14 +313,13 @@ bool JSContactWebSite::setType(JSContextRef context,
                        ContactWebSiteType type = converter->toContactWebSiteType(converter->toString(value));
                        webSite->setType(type);
                }
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
+       return true;
 }
 
 } // Contact
index 75b4974..e759ed4 100755 (executable)
@@ -32,6 +32,8 @@
 #include "plugin_config.h"
 #include "ContactConverter.h"
 #include "JSPerson.h"
+#include <ArgumentValidator.h>
+#include <JSWebAPIError.h>
 
 #define FILTER_CLASS_NAME               "Person"
 
@@ -76,11 +78,11 @@ JSClassDefinition JSPerson::m_classInfo =
 };
 
 JSStaticValue JSPerson::m_property[] = {
-       { CONTACT_ATTR_ID, getId, NULL, kJSPropertyAttributeReadOnly },
-       { CONTACT_ATTR_DISPLAY_NAME, getDisplayName, NULL, kJSPropertyAttributeReadOnly },
-       { CONTACT_ATTR_CONTACT_COUNT, getContactCount, NULL, kJSPropertyAttributeReadOnly },
-       { CONTACT_ATTR_HAS_PHONE_NUMBER, getHasPhoneNumber, NULL, kJSPropertyAttributeReadOnly },
-       { CONTACT_ATTR_HAS_EMAIL, getHasEmail, NULL, kJSPropertyAttributeReadOnly },
+       { CONTACT_ATTR_ID, getId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { CONTACT_ATTR_DISPLAY_NAME, getDisplayName, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { CONTACT_ATTR_CONTACT_COUNT, getContactCount, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { CONTACT_ATTR_HAS_PHONE_NUMBER, getHasPhoneNumber, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { CONTACT_ATTR_HAS_EMAIL, getHasEmail, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { CONTACT_ATTR_IS_FAVORITE, getIsFavorite, setIsFavorite, kJSPropertyAttributeNone },
        { CONTACT_ATTR_PHOTO_URI, getPhotoURI, setPhotoURI, kJSPropertyAttributeNone },
        { CONTACT_ATTR_RINGTONE_URI, getRingtoneURI, setRingtoneURI, kJSPropertyAttributeNone },
@@ -317,20 +319,16 @@ bool JSPerson::setIsFavorite(JSContextRef context,
        Try
        {
                PersonPtr person = getPrivData(object);
-               ContactConverterFactory::ConverterType converter =
-                               ContactConverterFactory::getConverter(context);
+               ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
                person->setIsFavorite(converter->toBool(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception,
-                       JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-
-       return false;
+       return true;
 }
 
 JSValueRef JSPerson::getPhotoURI(JSContextRef context,
@@ -367,23 +365,19 @@ bool JSPerson::setPhotoURI(JSContextRef context,
                PersonPtr person = getPrivData(object);
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
-               BasicValidator validator =
-                               BasicValidatorFactory::getValidator(context, exception);
+               BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
                if(validator->isNullOrUndefined(value))
                        person->unsetPhotoURI();
                else
                        person->setPhotoURI(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception,
-                       JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-
-       return false;
+       return true;
 }
 
 JSValueRef JSPerson::getRingtoneURI(JSContextRef context,
@@ -420,23 +414,19 @@ bool JSPerson::setRingtoneURI(JSContextRef context,
                PersonPtr person = getPrivData(object);
                ContactConverterFactory::ConverterType converter =
                                ContactConverterFactory::getConverter(context);
-               BasicValidator validator =
-                               BasicValidatorFactory::getValidator(context, exception);
+               BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
                if(validator->isNullOrUndefined(value))
                        person->unsetRingtoneURI();
                else
                        person->setRingtoneURI(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception,
-                       JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-
-       return false;
+       return true;
 }
 
 JSValueRef JSPerson::getDisplayContactId(JSContextRef context,
@@ -446,8 +436,7 @@ JSValueRef JSPerson::getDisplayContactId(JSContextRef context,
 {
        Try
        {
-               ContactConverterFactory::ConverterType converter =
-                               ContactConverterFactory::getConverter(context);
+               ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
                PersonPtr person = getPrivData(object);
                if(!person->getDisplayContactIdIsSet())
                        return JSValueMakeNull(context);
@@ -471,25 +460,20 @@ bool JSPerson::setDisplayContactId(JSContextRef context,
        Try
        {
                PersonPtr person = getPrivData(object);
-               ContactConverterFactory::ConverterType converter =
-                               ContactConverterFactory::getConverter(context);
-               BasicValidator validator =
-                               BasicValidatorFactory::getValidator(context, exception);
+               ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
+               BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
                if(validator->isNullOrUndefined(value))
                        person->unsetDisplayContactId();
                else
                        person->setDisplayContactId(converter->toString(value));
-               return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
                LogWarning("trying to set incorrect value");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
        }
 
-       JSTizenExceptionFactory::postException(context, exception,
-                       JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-
-       return false;
+       return true;
 }
 
 JSValueRef JSPerson::link(JSContextRef context,
@@ -518,35 +502,18 @@ JSValueRef JSPerson::link(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_PERSON_LINK);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try
-       {
-               if (argumentCount < 1)
-                       ThrowMsg(ConversionException, "1st argument must be 'PersonId'");
-       }
-       Catch (Exception)
-       {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'PersonId'");
-       }
-
+       ArgumentValidator validator(context, argumentCount, arguments);
        std::string personId;
-
-       ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
-       Try
-       {
-               personId = converter->toString(arguments[0]);
-
-               if (personId.empty())
-                       ThrowMsg(ConversionException, "1st argument must be 'PersonId'");
-
-       }
-       Catch(Exception)
-       {
-               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'PersonId'");
+       try     {
+               personId = validator.toString(0, false);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        EventPersonLinkPtr dplEvent(new EventPersonLink());
@@ -626,34 +593,18 @@ JSValueRef JSPerson::unlink(JSContextRef context,
        AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_PERSON_UNLINK);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try
-       {
-               if (argumentCount < 1)
-                       ThrowMsg(ConversionException, "1st argument must be 'ContactId'");
-
-               if (!JSValueIsString(context, arguments[0]))
-                       ThrowMsg(ConversionException, "1st argument must be 'ContactId'");
-       }
-       Catch (Exception)
-       {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactId'");
-       }
-
+       ArgumentValidator validator(context, argumentCount, arguments);
        std::string contactId;
-
-       ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
-       Try
-       {
-               contactId = converter->toString(arguments[0]);
-       }
-       Catch(Exception)
-       {
-               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactId'");
+       try     {
+               contactId = validator.toString(0, false);
+       } catch (const TypeMismatchException& err ) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const BasePlatformException& err) {
+               return JSWebAPIError::throwException(context, exception, err);
+       } catch(const ConversionException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
+       } catch(const NullPointerException& err) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "");
        }
 
        EventPersonUnlinkPtr dplEvent(new EventPersonUnlink());
@@ -710,6 +661,7 @@ JSValueRef JSPerson::unlink(JSContextRef context,
        }
 
        PersonPtr unlinkedPerson = dplEvent->getPerson();
+       ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
 
        JSValueRef result;
        Try
index 3e90dc7..eb59efc 100755 (executable)
@@ -33,7 +33,7 @@ static PropertyStructArray properties =
 {
        {"id",                                          PrimitiveType_String},
        {"displayName",                         PrimitiveType_String},
-       {"contactCount",                        PrimitiveType_Integer},
+       {"contactCount",                        PrimitiveType_Long},
        {"hasPhoneNumber",                      PrimitiveType_Boolean},
        {"hasEmail",                            PrimitiveType_Boolean},
        {"isFavorite",                          PrimitiveType_Boolean},
index b27054b..f5f8c5c 100755 (executable)
@@ -13,7 +13,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
 )
 
@@ -26,6 +25,7 @@ SET(SRCS_IMPL
        ContentConverter.cpp
        ContentFactory.cpp
        ContentFilterValidator.cpp
+       ContentFilterConverter.cpp
        ContentFolder.cpp
        ContentImage.cpp
        ContentManager.cpp
index 4616578..2c4fe39 100755 (executable)
@@ -19,6 +19,7 @@
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
+#include <JSUtil.h>
 
 #include "ContentConverter.h"
 #include "JSContent.h"
@@ -28,7 +29,7 @@
 #include "JSFolder.h"
 #include "JSAudioLyrics.h"
 
-
+using namespace DeviceAPI::Common;
 
 namespace DeviceAPI {
 namespace Content {
@@ -120,6 +121,25 @@ MediacontentMediaListPtr MediaConverter::toVectorOfMediaItem(JSValueRef events)
     for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
         JSValueRef element = JSGetArrayElement(m_context, objArg, i);
         JSObjectRef arg = JSValueToObject(m_context, element, NULL);
+
+        if(JSValueIsObjectOfClass(m_context, element, JSImage::getClassRef())){
+            JSValueRef geoValRef = JSUtil::getProperty(m_context , JSUtil::JSValueToObject(m_context, element), "geolocation");
+            JSObjectRef geoObjRef = JSUtil::JSValueToObject(m_context, geoValRef);
+            double latitude = JSUtil::JSValueToDouble(m_context, JSUtil::getProperty(m_context, geoObjRef, "latitude"));
+            double longitude = JSUtil::JSValueToDouble(m_context,JSUtil::getProperty(m_context, geoObjRef, "longitude"));
+            MediacontentImagePtr imgPtr = JSImage::getImageObject(arg);
+            imgPtr->setImageLatitude(latitude);
+            imgPtr->setImageLongitude(longitude);
+        }
+        if(JSValueIsObjectOfClass(m_context, element, JSVideo::getClassRef())){
+            JSValueRef geoValRef = JSUtil::getProperty(m_context , JSUtil::JSValueToObject(m_context, element), "geolocation");
+            JSObjectRef geoObjRef = JSUtil::JSValueToObject(m_context, geoValRef);
+            double latitude = JSUtil::JSValueToDouble(m_context, JSUtil::getProperty(m_context, geoObjRef, "latitude"));
+            double longitude = JSUtil::JSValueToDouble(m_context,JSUtil::getProperty(m_context, geoObjRef, "longitude"));
+            MediacontentVideoPtr vedioPtr = JSVideo::getVideoObject(arg);
+            vedioPtr->setVideoLatitude(latitude);
+            vedioPtr->setVideoLongitude(longitude);
+        }
         resultVector.push_back(JSMedia::getMediaObject(arg));
     }
     *result = resultVector;
diff --git a/src/Content/ContentFilterConverter.cpp b/src/Content/ContentFilterConverter.cpp
new file mode 100755 (executable)
index 0000000..799080c
--- /dev/null
@@ -0,0 +1,90 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file        ContentFilterConverter.cpp
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @description        Reference from CalendarConverter.cpp
+ */
+
+#include "ContentFilterConverter.h"
+
+#include <dpl/log/log.h>
+
+namespace DeviceAPI {
+namespace Content {
+
+using namespace std;
+using namespace DeviceAPI::Tizen;
+
+static PropertyStructArray folderProperties =
+{
+               { "id",                     PrimitiveType_String },
+               { "directoryURI",           PrimitiveType_String },
+               { "storageType",            PrimitiveType_String },
+               { "title",                  PrimitiveType_String },
+               { "modifiedDate",           PrimitiveType_Time },
+               { 0,                        PrimitiveType_NoType}
+};
+
+static PropertyStructArray mediaProperties =
+{
+               { "id",                     PrimitiveType_String },
+               { "type",                   PrimitiveType_String },
+               { "mimeType",               PrimitiveType_String },
+               { "name",                   PrimitiveType_String },
+               { "title",                  PrimitiveType_String },
+               { "contentURI",             PrimitiveType_String },
+               { "thumbnailURIs",          PrimitiveType_String },
+               { "description",            PrimitiveType_String },
+               { "rating",                 PrimitiveType_Long },
+               { "releaseDate",            PrimitiveType_Time },
+               { "modifiedDate",           PrimitiveType_Time },
+               { "geolocation.latitude",   PrimitiveType_Double },
+               { "geolocation.longitude",      PrimitiveType_Double },
+               { "album",                  PrimitiveType_String },
+               { "artists",                PrimitiveType_String },
+               { "width",                  PrimitiveType_String },
+               { "height",                 PrimitiveType_String },
+               { "genres",                 PrimitiveType_String },
+               { 0,                        PrimitiveType_NoType}
+};
+
+FolderContentFilterConverter::FolderContentFilterConverter(JSContextRef context) :
+               FilterConverter(context, folderProperties, false)
+{
+}
+
+FolderContentFilterConverter::~FolderContentFilterConverter()
+{
+       LogDebug("entered");
+}
+
+MediaContentFilterConverter::MediaContentFilterConverter(JSContextRef context) :
+               FilterConverter(context, mediaProperties, false)
+{
+}
+
+MediaContentFilterConverter::~MediaContentFilterConverter()
+{
+       LogDebug("entered");
+}
+
+} // Content
+} // DeviceAPI
+
diff --git a/src/Content/ContentFilterConverter.h b/src/Content/ContentFilterConverter.h
new file mode 100644 (file)
index 0000000..ca5f65d
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file        ContentFilterConverter.h
+ * @version     0.1
+ * @description        Reference from CalendarConverter.h
+ */
+
+#ifndef _TIZEN_CONTENT_FILTER_CONVERTER_H_
+#define _TIZEN_CONTENT_FILTER_CONVERTER_H_
+
+#include <set>
+#include <string>
+#include <FilterConverter.h>
+
+namespace DeviceAPI {
+namespace Content {
+
+class FolderContentFilterConverter : public DeviceAPI::Tizen::FilterConverter
+{
+public:
+       explicit FolderContentFilterConverter(JSContextRef context);
+       virtual ~FolderContentFilterConverter();
+};
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<FolderContentFilterConverter> FolderContentFilterConverterFactory;
+
+class MediaContentFilterConverter : public DeviceAPI::Tizen::FilterConverter
+{
+public:
+       explicit MediaContentFilterConverter(JSContextRef context);
+       virtual ~MediaContentFilterConverter();
+};
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<MediaContentFilterConverter> MediaContentFilterConverterFactory;
+
+} // Content
+} // DeviceAPI
+
+#endif // _TIZEN_CONTENT_FILTER_CONVERTER_H_
+
index d735276..17517a4 100755 (executable)
@@ -43,8 +43,8 @@ static PropertyStructArray mediaProperties =
        {"contentURI",          PrimitiveType_String},
        {"thumbnailURIs",       PrimitiveType_String},
        {"description",         PrimitiveType_String},
-       {"rating",                      PrimitiveType_Int},     
-       {"releasedDate",                PrimitiveType_Time},
+       {"rating",                      PrimitiveType_Long},
+       {"releaseDate",         PrimitiveType_Time},
        {"modifiedDate",                PrimitiveType_Time},
        {"geolocation.latitude",        PrimitiveType_Double},
        {"geolocation.longitude",       PrimitiveType_Double},  
index a65e858..50850b2 100755 (executable)
@@ -188,38 +188,38 @@ string MediaSearchVisitor::convertAttribute(string &attrName, AnyPtr& matchValue
 
        if(attrName.compare("MEDIA_TYPE")==0)
        {
-               if(matchValue->toString().compare("IMAGE")==0)
+               if(matchValue->getString().compare("IMAGE")==0)
                        matchValueStr = "0";
-               else if(matchValue->toString().compare("VIDEO")==0)
+               else if(matchValue->getString().compare("VIDEO")==0)
                        matchValueStr = "1";
-               else if(matchValue->toString().compare("AUDIO")==0)
+               else if(matchValue->getString().compare("AUDIO")==0)
                        matchValueStr = "3";
-               else if(matchValue->toString().compare("OTHER")==0)
+               else if(matchValue->getString().compare("OTHER")==0)
                        matchValueStr = "4";
                else
                {
-                       ThrowMsg(PlatformException, "mediaType(" << matchValue->toString() << ") is not supported.");
+                       ThrowMsg(PlatformException, "mediaType(" << matchValue->getString() << ") is not supported.");
                }
        }
        else if(attrName.compare("contentURI")==0 || attrName.compare("thumbnailURIs")==0)
        {
-               matchValueStr = ContentUtility::convertUriToPath(matchValue->toString());
+               matchValueStr = ContentUtility::convertUriToPath(matchValue->getString());
        }
        else
        {
                matchValueStr = matchValue->toString();
        }
 
-       if(matchValue->getType() == PrimitiveType_Time)
+       if(matchValue->isType(PrimitiveType_Time))
        {
-               tm date = matchValue->getDateTm();
+               tm date = *matchValue->getDateTm();
                valueStr = toDateDbStr(date);
                cond = EQUAL;
        }
        else
        {
                //STARTSWITH('%, ENDSWITH, EXISTS
-               //valueStr = matchValue->toString();
+               //valueStr = matchValue->getString();
        
                ostringstream os;
 
@@ -266,9 +266,9 @@ void MediaSearchVisitor::visitAttributeRange(string& attrName,AnyPtr& initialVal
 
        if(!initialValue->isNullOrUndefined()) 
        {
-               if(initialValue->getType() == PrimitiveType_Time) 
+               if(initialValue->isType(PrimitiveType_Time))
                {
-                       tm date = initialValue->getDateTm();
+                       tm date = *initialValue->getDateTm();
                        initialValueStr = toDateDbStr(date);
 
                } 
@@ -280,9 +280,9 @@ void MediaSearchVisitor::visitAttributeRange(string& attrName,AnyPtr& initialVal
 
        if (!endValue->isNullOrUndefined()) 
        {
-               if(endValue->getType() == PrimitiveType_Time) 
+               if(endValue->isType(PrimitiveType_Time))
                {
-                       tm date = endValue->getDateTm();
+                       tm date = *endValue->getDateTm();
                        endValueStr = toDateDbStr(date);
                }
                else 
index ef76450..26ec105 100755 (executable)
@@ -49,6 +49,7 @@
 #include "ContentListener.h"
 #include "ContentVideo.h"
 #include "ContentImage.h"
+#include "ContentFilterConverter.h"
 
 
 using namespace DeviceAPI::Common;
@@ -234,7 +235,7 @@ JSValueRef JSMediacontentManager::findItems(
        JSContextRef globalContext = privateObject->getContext();
        Validator validator(context);
     JSCallbackManagerPtr cbm(NULL);
-    FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+    MediaContentFilterConverterFactory::ConverterType filterConverter = MediaContentFilterConverterFactory::getConverter(context);
        MediaConverterFactory::ConverterType converter = MediaConverterFactory::getConverter(context);
        MediaConverter mediaConverter(globalContext);
 
index b5dd618..eb4786d 100755 (executable)
@@ -12,7 +12,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
 )
 
index fc86234..21c3076 100755 (executable)
@@ -6,7 +6,6 @@ PKG_CHECK_MODULES(platform_pkgs_datasync REQUIRED sync-agent)
 
 INCLUDE_DIRECTORIES(
        ${TOP}/Tizen
-       ${TOP}/TimeUtil
        ${TOP}/Common
        ${platform_pkgs_datasync_INCLUDE_DIRS}
 )
@@ -14,7 +13,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
 )
 
index 903860f..076ae96 100755 (executable)
@@ -293,8 +293,7 @@ bool JSSyncInfo::setProperty(JSContextRef context,
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
     }
 
-    JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
-    return false;
+    return true;
 }
 
 }
index d523e04..3c963cf 100755 (executable)
@@ -55,7 +55,7 @@ JSClassDefinition JSSyncProfileInfo::m_classInfo = {
 };
 
 JSStaticValue JSSyncProfileInfo::m_property[] = {
-    { TIZEN_SYNC_PROFILE_INFO_PROFILE_ID, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_SYNC_PROFILE_INFO_PROFILE_ID, getProperty, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { TIZEN_SYNC_PROFILE_INFO_PROFILE_NAME, getProperty, setProperty, kJSPropertyAttributeNone },
     { TIZEN_SYNC_PROFILE_INFO_SYNC_INFO, getProperty, setProperty, kJSPropertyAttributeNone },
        { TIZEN_SYNC_PROFILE_INFO_SERVICE_INFO, getProperty, setProperty, kJSPropertyAttributeNone },
@@ -270,8 +270,7 @@ bool JSSyncProfileInfo::setProperty(JSContextRef context,
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
     }
 
-    JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
-    return false;
+    return true;
 }
 
 }
index 1ff3d56..b66e07b 100755 (executable)
@@ -278,8 +278,7 @@ bool JSSyncServiceInfo::setProperty(JSContextRef context,
                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
     }
 
-    JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
-    return false;
+    return true;
 }
 
 }
index cebeb6d..440b48e 100755 (executable)
@@ -52,17 +52,17 @@ JSClassDefinition JSSyncStatistics::m_classInfo = {
 };
 
 JSStaticValue JSSyncStatistics::m_property[] = {
-    { TIZEN_SYNC_STATISTICS_SYNC_STATUS, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_SYNC_STATISTICS_SERVICE_TYPE, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_SYNC_STATISTICS_LAST_SYNC_TIME, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_SYNC_STATISTICS_SERVER_TO_CLIENT_TOTAL, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_SYNC_STATISTICS_SERVER_TO_CLIENT_ADDED, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_SYNC_STATISTICS_SERVER_TO_CLIENT_UPDATED, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_SYNC_STATISTICS_SERVER_TO_CLIENT_REMOVED, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_SYNC_STATISTICS_CLIENT_TO_SERVER_TOTAL, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_SYNC_STATISTICS_CLIENT_TO_SERVER_ADDED, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_SYNC_STATISTICS_CLIENT_TO_SERVER_UPDATED, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { TIZEN_SYNC_STATISTICS_CLIENT_TO_SERVER_REMOVED, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_SYNC_STATISTICS_SYNC_STATUS, getProperty, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_SYNC_STATISTICS_SERVICE_TYPE, getProperty, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_SYNC_STATISTICS_LAST_SYNC_TIME, getProperty, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_SYNC_STATISTICS_SERVER_TO_CLIENT_TOTAL, getProperty, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_SYNC_STATISTICS_SERVER_TO_CLIENT_ADDED, getProperty, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_SYNC_STATISTICS_SERVER_TO_CLIENT_UPDATED, getProperty, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_SYNC_STATISTICS_SERVER_TO_CLIENT_REMOVED, getProperty, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_SYNC_STATISTICS_CLIENT_TO_SERVER_TOTAL, getProperty, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_SYNC_STATISTICS_CLIENT_TO_SERVER_ADDED, getProperty, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_SYNC_STATISTICS_CLIENT_TO_SERVER_UPDATED, getProperty, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+       { TIZEN_SYNC_STATISTICS_CLIENT_TO_SERVER_REMOVED, getProperty, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
 
     { 0, 0, 0, 0 }
 };
index 0dfb4d7..e4acd49 100755 (executable)
@@ -13,7 +13,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${filesystem_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
 )
index 30f4258..1935315 100755 (executable)
@@ -15,8 +15,6 @@
 // limitations under the License.
 //
 
-#include <CommonsJavaScript/JSUtils.h>
-
 #include <JSWebAPIError.h>
 #include <PlatformException.h>
 #include <JSUtil.h>
@@ -36,7 +34,7 @@ DownloadCallback::DownloadCallback(JSContextRef globalCtx, JSObjectRef object)
        mCallbackUserData = new MultiCallbackUserData(globalCtx);
 
        // onprogress
-       JSValueRef onprogress = JSUtils::getJSPropertyOrUndefined(globalCtx, object, "onprogress");
+       JSValueRef onprogress = JSUtil::getProperty(globalCtx, object, "onprogress");
        if (JSValueIsUndefined(globalCtx, onprogress)) {
                onprogress = NULL;
        } else {
@@ -49,7 +47,7 @@ DownloadCallback::DownloadCallback(JSContextRef globalCtx, JSObjectRef object)
        }
 
        // onpaused
-       JSValueRef onpaused = JSUtils::getJSPropertyOrUndefined(globalCtx, object, "onpaused");
+       JSValueRef onpaused = JSUtil::getProperty(globalCtx, object, "onpaused");
        if (JSValueIsUndefined(globalCtx, onpaused)) {
                onpaused = NULL;
        } else {
@@ -62,7 +60,7 @@ DownloadCallback::DownloadCallback(JSContextRef globalCtx, JSObjectRef object)
        }
 
        // oncanceled
-       JSValueRef oncanceled = JSUtils::getJSPropertyOrUndefined(globalCtx, object, "oncanceled");
+       JSValueRef oncanceled = JSUtil::getProperty(globalCtx, object, "oncanceled");
        if (JSValueIsUndefined(globalCtx, oncanceled)) {
                oncanceled = NULL;
        } else {
@@ -75,7 +73,7 @@ DownloadCallback::DownloadCallback(JSContextRef globalCtx, JSObjectRef object)
        }
 
        // oncompleted
-       JSValueRef oncompleted = JSUtils::getJSPropertyOrUndefined(globalCtx, object, "oncompleted");
+       JSValueRef oncompleted = JSUtil::getProperty(globalCtx, object, "oncompleted");
        if (JSValueIsUndefined(globalCtx, oncompleted)) {
                oncompleted = NULL;
        } else {
@@ -88,7 +86,7 @@ DownloadCallback::DownloadCallback(JSContextRef globalCtx, JSObjectRef object)
        }
 
        // onfailed
-       JSValueRef onfailed = JSUtils::getJSPropertyOrUndefined(globalCtx, object, "onfailed");
+       JSValueRef onfailed = JSUtil::getProperty(globalCtx, object, "onfailed");
        if (JSValueIsUndefined(globalCtx, onfailed)) {
                onfailed = NULL;
        } else {
index fff964e..f489683 100644 (file)
@@ -125,7 +125,6 @@ typedef struct {
        void *user_data;
 } DOWNLOAD_EVENT_DATA_T;
 
-
 static gboolean downloadEventCB(void *data) {
        int ret;
 
@@ -276,7 +275,7 @@ static void download_state_changed_cb(int downloadId, download_state_e state, vo
        data->received = 0;
        data->user_data = user_data;
 
-       // download core f/w calls this callback function in another thread. 
+       // download core f/w calls this callback function in another thread.
        // so we should use g_idle_add() to switch context to main thread.
        g_idle_add(downloadEventCB, static_cast<void*>(data));
 }
@@ -290,7 +289,7 @@ static void download_progress_cb(int downloadId, unsigned long long received, vo
        data->received = received;
        data->user_data = user_data;
 
-       // download core f/w calls this callback function in another thread. 
+       // download core f/w calls this callback function in another thread.
        // so we should use g_idle_add() to switch context to main thread.
        g_idle_add(downloadEventCB, static_cast<void*>(data));
 }
@@ -441,7 +440,7 @@ void DownloadManager::cancel(long downloadId)
                } else if (ret == DOWNLOAD_ERROR_INVALID_PARAMETER) {
                        throw InvalidValuesException("download id is not valid.");
                }
-               throw UnknownException(("Platform error while canceling download. " + _get_download_error(ret)).c_str()); 
+               throw UnknownException(("Platform error while canceling download. " + _get_download_error(ret)).c_str());
        }
 }
 
@@ -458,7 +457,7 @@ void DownloadManager::pause(long downloadId)
                } else if (ret == DOWNLOAD_ERROR_INVALID_PARAMETER) {
                        throw InvalidValuesException("download id is not valid.");
                }
-               throw UnknownException(("Platform error while pausing download. " + _get_download_error(ret)).c_str()); 
+               throw UnknownException(("Platform error while pausing download. " + _get_download_error(ret)).c_str());
        }
 }
 
@@ -475,7 +474,7 @@ void DownloadManager::resume(long downloadId)
                } else if (ret == DOWNLOAD_ERROR_INVALID_PARAMETER) {
                        throw InvalidValuesException("download id is not valid.");
                }
-               throw UnknownException(("Platform error while resuming download. " + _get_download_error(ret)).c_str()); 
+               throw UnknownException(("Platform error while resuming download. " + _get_download_error(ret)).c_str());
        }
 }
 
@@ -494,7 +493,7 @@ std::string DownloadManager::getState(long downloadId)
                } else if (ret == DOWNLOAD_ERROR_INVALID_PARAMETER) {
                        throw InvalidValuesException("download id is not valid.");
                }
-               throw UnknownException(("Platform error while getting state. " + _get_download_error(ret)).c_str()); 
+               throw UnknownException(("Platform error while getting state. " + _get_download_error(ret)).c_str());
        }
 
        switch (state) {
@@ -664,7 +663,7 @@ std::string DownloadManager::getMIMEType(long downloadId)
                } else if (ret == DOWNLOAD_ERROR_NO_DATA) {
                        result = "";
                } else {
-                       throw UnknownException(("Platform error while getting MIME type. " + _get_download_error(ret)).c_str()); 
+                       throw UnknownException(("Platform error while getting MIME type. " + _get_download_error(ret)).c_str());
                }
        } else {
                result = mimeType;
index 3b9e915..23e8726 100755 (executable)
@@ -178,10 +178,12 @@ DownloadRequest* JSDownloadRequest::getPrivateObject(JSContextRef context, JSObj
 
 void JSDownloadRequest::setPrivateObject(JSContextRef context, JSObjectRef object, DownloadRequest* priv)
 {
-       if (priv) {
-               JSObjectSetPrivate(object, static_cast<void*>(priv));
+       if (!priv) {
+               throw TypeMismatchException("DownloadRequest's private object is NULL.");
        }
 
+    JSObjectSetPrivate(object, static_cast<void*>(priv));
+
        // url
        JSUtil::setProperty(context, object, TIZEN_DOWNLOAD_REQUEST_URL,
                        JSUtil::toJSValueRef(context, priv->getUrl()), kJSPropertyAttributeNone);
index 63781de..040f466 100755 (executable)
@@ -13,7 +13,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
 )
 
index f340add..e2548a6 100755 (executable)
@@ -79,7 +79,7 @@ void ResponseDispatcher::OnAnswerReceived(const EventResolvePtr& event)
                if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
                        jsException = JSTizenExceptionFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSTizenException::NOT_FOUND_ERROR, "NotFoundError");
                } else {
-                       JSTizenExceptionFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error");
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error");
                }
                data->getCallbackManager()->callOnError(jsException);
        }
index 6697947..af784ba 100644 (file)
@@ -148,9 +148,8 @@ JSValueRef JSMessagePortManager::requestLocalMessagePort(JSContextRef context,
                                JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       // TODO To decide the privilege
-       //AceSecurityStatus status = MESSAGE_PORT_CHECK_ACCESS(MESSAGE_PORT_FUNCTION_API_REQUEST_LOCAL_MESSAGE_PORT);
-       //TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       AceSecurityStatus status = MESSAGE_PORT_CHECK_ACCESS(MESSAGE_PORT_FUNCTION_API_REQUEST_LOCAL_MESSAGE_PORT);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try
@@ -273,9 +272,8 @@ JSValueRef JSMessagePortManager::requestTrustedLocalMessagePort(JSContextRef con
                                JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       // TODO To decide the privilege
-       //AceSecurityStatus status = MESSAGE_PORT_CHECK_ACCESS(MESSAGE_PORT_FUNCTION_API_REQUEST_TRUSTED_LOCAL_MESSAGE_PORT);
-       //TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       AceSecurityStatus status = MESSAGE_PORT_CHECK_ACCESS(MESSAGE_PORT_FUNCTION_API_REQUEST_TRUSTED_LOCAL_MESSAGE_PORT);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try
@@ -398,9 +396,8 @@ JSValueRef JSMessagePortManager::requestRemoteMessagePort(JSContextRef context,
                                JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       // TODO To decide the privilege
-       //AceSecurityStatus status = MESSAGE_PORT_CHECK_ACCESS(MESSAGE_PORT_FUNCTION_API_REQUEST_LOCAL_MESSAGE_PORT);
-       //TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       AceSecurityStatus status = MESSAGE_PORT_CHECK_ACCESS(MESSAGE_PORT_FUNCTION_API_REQUEST_LOCAL_MESSAGE_PORT);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try
@@ -543,9 +540,8 @@ JSValueRef JSMessagePortManager::requestTrustedRemoteMessagePort(JSContextRef co
                                JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       // TODO To decide the privilege
-       //AceSecurityStatus status = MESSAGE_PORT_CHECK_ACCESS(MESSAGE_PORT_FUNCTION_API_REQUEST_LOCAL_MESSAGE_PORT);
-       //TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       AceSecurityStatus status = MESSAGE_PORT_CHECK_ACCESS(MESSAGE_PORT_FUNCTION_API_REQUEST_LOCAL_MESSAGE_PORT);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try
index 65d81c1..40acb17 100644 (file)
 #include "plugin_config.h"
 
 #define MESSAGE_PORT_FEATURE_API_OPENED  "http://tizen.org/privilege/messageport"
-#define MESSAGE_PORT_FEATURE_API_TRUSTED  "http://tizen.org/privilege/messageport.trusted"
 
 #define MESSAGE_PORT_DEVICE_CAP_OPENED "messageport"
-#define MESSAGE_PORT_DEVICE_CAP_TRUSTED "messageport.trusted"
 
 using namespace WrtDeviceApis::Commons;
 
@@ -49,32 +47,19 @@ static FunctionMapping createMessagePortFunctions()
      * Device capabilities
      */
     ACE_CREATE_DEVICE_CAP(DEVICE_CAP_MESSAGE_PORT_OPENED, MESSAGE_PORT_DEVICE_CAP_OPENED);
-    ACE_CREATE_DEVICE_CAP(DEVICE_CAP_MESSAGE_PORT_TRUSTED, MESSAGE_PORT_DEVICE_CAP_TRUSTED);
 
     ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
 
     ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_MESSAGE_PORT_OPENED);
     ACE_ADD_DEVICE_CAP(DEVICE_LIST_MESSAGE_PORT_OPENED, DEVICE_CAP_MESSAGE_PORT_OPENED);
 
-    ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_MESSAGE_PORT_TRUSTED);
-    ACE_ADD_DEVICE_CAP(DEVICE_LIST_MESSAGE_PORT_TRUSTED, DEVICE_CAP_MESSAGE_PORT_OPENED);
-    ACE_ADD_DEVICE_CAP(DEVICE_LIST_MESSAGE_PORT_TRUSTED, DEVICE_CAP_MESSAGE_PORT_TRUSTED);
-
     /**
      * Api Features
      */
     ACE_CREATE_FEATURE(FEATURE_MESSAGE_PORT_OPENED, MESSAGE_PORT_FEATURE_API_OPENED);
-    ACE_CREATE_FEATURE(FEATURE_MESSAGE_PORT_TRUSTED, MESSAGE_PORT_FEATURE_API_TRUSTED);
 
     ACE_CREATE_FEATURE_LIST(MESSAGE_PORT_FEATURES_MESSAGE_PORT);
     ACE_ADD_API_FEATURE(MESSAGE_PORT_FEATURES_MESSAGE_PORT, FEATURE_MESSAGE_PORT_OPENED);
-    ACE_ADD_API_FEATURE(MESSAGE_PORT_FEATURES_MESSAGE_PORT, FEATURE_MESSAGE_PORT_TRUSTED);
-
-    ACE_CREATE_FEATURE_LIST(MESSAGE_PORT_FEATURES_MESSAGE_PORT_OPENED);
-    ACE_ADD_API_FEATURE(MESSAGE_PORT_FEATURES_MESSAGE_PORT_OPENED, FEATURE_MESSAGE_PORT_OPENED);
-
-    ACE_CREATE_FEATURE_LIST(MESSAGE_PORT_FEATURES_MESSAGE_PORT_TRUSTED);
-    ACE_ADD_API_FEATURE(MESSAGE_PORT_FEATURES_MESSAGE_PORT_TRUSTED, FEATURE_MESSAGE_PORT_TRUSTED);
 
     /**
      * Functions
@@ -98,7 +83,7 @@ static FunctionMapping createMessagePortFunctions()
             FUNCTION_MESSAGE_PORT_MANAGER_REQUEST_TRUSTED_LOCAL_MESSAGE_PORT,
             MESSAGE_PORT_FUNCTION_API_REQUEST_TRUSTED_LOCAL_MESSAGE_PORT,
             MESSAGE_PORT_FEATURES_MESSAGE_PORT,
-            DEVICE_LIST_MESSAGE_PORT_TRUSTED);
+            DEVICE_LIST_MESSAGE_PORT_OPENED);
 
     messagePortMapping.insert(std::make_pair(
                                   MESSAGE_PORT_FUNCTION_API_REQUEST_TRUSTED_LOCAL_MESSAGE_PORT,
@@ -120,7 +105,7 @@ static FunctionMapping createMessagePortFunctions()
             FUNCTION_MESSAGE_PORT_MANAGER_REQUEST_TRUSTED_REMOTE_MESSAGE_PORT,
             MESSAGE_PORT_FUNCTION_API_REQUEST_TRUSTED_REMOTE_MESSAGE_PORT,
             MESSAGE_PORT_FEATURES_MESSAGE_PORT,
-            DEVICE_LIST_MESSAGE_PORT_TRUSTED);
+            DEVICE_LIST_MESSAGE_PORT_OPENED);
 
     messagePortMapping.insert(std::make_pair(
                                   MESSAGE_PORT_FUNCTION_API_REQUEST_TRUSTED_REMOTE_MESSAGE_PORT,
index 5272832..03c9c68 100755 (executable)
@@ -14,7 +14,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${filesystem_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
 )
@@ -114,6 +113,7 @@ SET(SRCS_MESSAGING
        JSMessageAttachment.cpp
        MessageAsyncCallbackManager.cpp
        MessageListenerManager.cpp
+       MessageFilterConverter.cpp
 )
 
 SET(SRCS_IMPL
@@ -147,4 +147,4 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_L
 INSTALL(
        DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/messaging
        FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE
-)
\ No newline at end of file
+)
index 1201a62..7eb3eb0 100755 (executable)
@@ -36,8 +36,8 @@ namespace DeviceAPI {
                                {ConversationFilterValidatorFactory::ATTRIBUTE_ID.c_str(),              DeviceAPI::Tizen::PrimitiveType_String},
                                {ConversationFilterValidatorFactory::ATTRIBUTE_TYPE.c_str(),            DeviceAPI::Tizen::PrimitiveType_String},
                                {ConversationFilterValidatorFactory::ATTRIBUTE_TIMESTAMP.c_str(),       DeviceAPI::Tizen::PrimitiveType_Time},
-                               {ConversationFilterValidatorFactory::ATTRIBUTE_MESSAGE_COUNT.c_str(),   DeviceAPI::Tizen::PrimitiveType_Number},
-                               {ConversationFilterValidatorFactory::ATTRIBUTE_UNREAD_MESSAGES.c_str(), DeviceAPI::Tizen::PrimitiveType_Number},
+                               {ConversationFilterValidatorFactory::ATTRIBUTE_MESSAGE_COUNT.c_str(),   DeviceAPI::Tizen::PrimitiveType_ULong},
+                               {ConversationFilterValidatorFactory::ATTRIBUTE_UNREAD_MESSAGES.c_str(), DeviceAPI::Tizen::PrimitiveType_ULong},
                                {ConversationFilterValidatorFactory::ATTRIBUTE_PREVIEW.c_str(),         DeviceAPI::Tizen::PrimitiveType_String},
                                {ConversationFilterValidatorFactory::ATTRIBUTE_FROM.c_str(),            DeviceAPI::Tizen::PrimitiveType_String},
                                {ConversationFilterValidatorFactory::ATTRIBUTE_TO.c_str(),              DeviceAPI::Tizen::PrimitiveType_String},
index fbb6900..af6232c 100755 (executable)
@@ -18,6 +18,7 @@
 #include "ConversationQueryGenerator.h"
 #include "ConversationFilterValidatorFactory.h"
 
+#include <Commons/Exception.h>
 #include <dpl/log/log.h>
 #include "log.h"
 
index 88ce628..9462000 100644 (file)
@@ -21,8 +21,6 @@
 #include <dpl/log/log.h>
 #include "log.h"
 
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace DeviceAPI::Tizen;
 
 namespace DeviceAPI {
index de7fd09..9eb17e6 100755 (executable)
@@ -143,11 +143,6 @@ namespace DeviceAPI {
                        LogDebug("<<< NOT IMPLEMENTED YET");
                }
 
-               //TODO implement visitID
-               void FolderQueryGenerator::visitID(DeviceAPI::Tizen::AnyArrayPtr &value, int depth) {
-                       LogDebug("<<< NOT IMPLEMENTED YET");
-               }
-
                int FolderQueryGenerator::getAccountId()
                {
                        return m_accountId;
index 61d367e..9ac272a 100644 (file)
@@ -72,7 +72,6 @@ public:
        void visitAttributeRange(std::string& attrName,
                        DeviceAPI::Tizen::AnyPtr& initialValue, DeviceAPI::Tizen::AnyPtr& endValue,
                        int depth);
-       void visitID(DeviceAPI::Tizen::AnyArrayPtr &value, int depth);
 
        int getAccountId();
        std::string getFolderPath();
index 96cb6c7..a9939eb 100644 (file)
@@ -560,7 +560,15 @@ JSValueRef JSMessage::getAttachments(JSContextRef context,
                                return result;
                        }
                        case SMS:
-                               return JSValueMakeNull(context);
+                       {
+                               JSObjectRef arrayValue = JSCreateArrayObject(context, 0, NULL);
+                               if (NULL == arrayValue)
+                               {
+                                       LogError("Could not create js array object");
+                                       return JSValueMakeUndefined(context);
+                               }
+                               return arrayValue;
+                       }
                        default:
                                LogError("not supported message type");
                                Throw(WrtDeviceApis::Commons::InvalidArgumentException);
@@ -605,14 +613,24 @@ JSValueRef JSMessage::getBccAddress(JSContextRef context,
                                }
                                for(size_t i = 0; i < recipient->getRecipientSize(); i++)
                                {
-                                       JSSetArrayElement(context, arrayValue, i, converter->toJSValueRef(recipient->getRecipient(i)));
+                                       if(!JSSetArrayElement(context, arrayValue, i, converter->toJSValueRef(recipient->getRecipient(i))))
+                       {
+                                               ThrowMsg(ConversionException, "Could not insert value into js array");
+                       }
                                }
                                return arrayValue;
                        }
                        case SMS:
                        case MMS:
-                               return JSValueMakeNull(context);
-
+                       {
+                               JSObjectRef arrayValue = JSCreateArrayObject(context, 0, NULL);
+                               if (NULL == arrayValue)
+                               {
+                                       LogError("Could not create js array object");
+                                       return JSValueMakeUndefined(context);
+                               }
+                               return arrayValue;
+                       }
                        default:
                                LogError("not supported message type");
                                return JSTizenExceptionFactory::postException(context, exception,
@@ -682,14 +700,24 @@ JSValueRef JSMessage::getCcAddress(JSContextRef context,
                                }
                                for(size_t i = 0; i < recipient->getRecipientSize(); i++)
                                {
-                                       JSSetArrayElement(context, arrayValue, i, converter->toJSValueRef(recipient->getRecipient(i)));
+                                       if(!JSSetArrayElement(context, arrayValue, i, converter->toJSValueRef(recipient->getRecipient(i))))
+                       {
+                                               ThrowMsg(ConversionException, "Could not insert value into js array");
+                       }
                                }
                                return arrayValue;
                        }
                        case MMS:
                        case SMS:
-                               return JSValueMakeNull(context);
-
+                       {
+                               JSObjectRef arrayValue = JSCreateArrayObject(context, 0, NULL);
+                               if (NULL == arrayValue)
+                               {
+                                       LogError("Could not create js array object");
+                                       return JSValueMakeUndefined(context);
+                               }
+                               return arrayValue;
+                       }
                        default:
                                LogError("not supported message type");
                                return JSTizenExceptionFactory::postException(context, exception, 
@@ -727,9 +755,13 @@ JSValueRef JSMessage::getDestinationAddress(JSContextRef context,
                        LogError("Could not create js array object");
                        return JSValueMakeUndefined(context);
                }
+               LogError("recipient->getRecipientSize() : " << recipient->getRecipientSize());
                for(size_t i = 0; i < recipient->getRecipientSize(); i++)
                {
-                       JSSetArrayElement(context, arrayValue, i, converter->toJSValueRef(recipient->getRecipient(i)));
+                       if(!JSSetArrayElement(context, arrayValue, i, converter->toJSValueRef(recipient->getRecipient(i))))
+                       {
+                               ThrowMsg(ConversionException, "Could not insert value into js array");
+                       }
                }
                return arrayValue;
        }
@@ -813,7 +845,8 @@ JSValueRef JSMessage::getMessagePriority(JSContextRef context,
                switch (msgType) {
                        case SMS:
                        case MMS:
-                               return JSValueMakeNull(context);
+                               LogError("priority : false");
+                               return converter->toJSValueRef(false);
                        case EMAIL:
                        {
                                IEmailPtr email = MessageFactory::convertToEmail(msg);
@@ -878,14 +911,14 @@ JSValueRef JSMessage::getSourceAddress(JSContextRef context,
        {
                ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
                IMessagePtr msg = converter->toIMessage(object);
-
-               //This property is set up by the device or the web runtime environment.
-               //This property should only be taken into account for Email.
-               // TODO Verify with Tizen.
-               //        if (msg->getMessageType() != EMAIL && msg->getMessageType() != Api::VIRTUAL_MESSAGE) {
-               //            return JSValueMakeUndefined(context);
-               //        }
-               return converter->toJSValueRef(msg->getSourceAddress());
+               string from = msg->getSourceAddress();
+               LogDebug("from =" << from);
+               if(from.size() == 0)
+               {
+                       LogDebug("JSValueMakeNull");
+                       return JSValueMakeNull(context);
+               }
+               return converter->toJSValueRef(from);
        }
        Catch(WrtDeviceApis::Commons::ConversionException) {
                LogError("Error on conversion");
@@ -914,6 +947,7 @@ JSValueRef JSMessage::getSubject(JSContextRef context,
                        case MMS:
                        {
                                IMmsPtr mms = MessageFactory::convertToMms(msg);
+                               //JSValueMakeUndefined
                                return converter->toJSValueRef(mms->getSubject());
                        }
                        case EMAIL:
@@ -922,7 +956,7 @@ JSValueRef JSMessage::getSubject(JSContextRef context,
                                return converter->toJSValueRef(email->getSubject());
                        }
                        case SMS:
-                               return JSValueMakeNull(context);
+                               return converter->toJSValueRef("");
                        default:
                                LogError("message not support subject");
                                return JSTizenExceptionFactory::postException(context, exception,
@@ -956,6 +990,14 @@ JSValueRef JSMessage::getTime(JSContextRef context,
                ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
                IMessagePtr msg = converter->toIMessage(object);
                struct tm dateTime = msg->getDateTime();
+               const string& id = msg->getIdRef();
+               LogDebug("msg->getMessageStatus()=" << msg->getMessageStatus());
+               LogInfo("id.size() : " << id.size());
+               if((id.size() == 0) && msg->getMessageStatus() == MESSAGE_STATUS_CREATED)
+               {
+                       LogInfo("JSValueMakeNull");
+                       return JSValueMakeNull(context);
+               }               
                return converter->toJSValueRef(dateTime);
        }
        Catch(WrtDeviceApis::Commons::ConversionException) {
@@ -1248,8 +1290,6 @@ bool JSMessage::setAttachments(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::ConversionException) {
                LogError("Error on conversion");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
        }
        Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
                LogError("Invalid argument exception");
@@ -1401,8 +1441,6 @@ bool JSMessage::setBccAddress(JSContextRef context,
        }
        Catch(WrtDeviceApis::Commons::ConversionException) {
                LogError("Error on conversion");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
        }
        Catch(WrtDeviceApis::Commons::NullPointerException) {
                LogError("Error on pointer, null value");
@@ -1713,16 +1751,6 @@ JSValueRef JSMessage::getConversationId(JSContextRef context,
                        return JSValueMakeNull(context);
                }
                return converter->toJSValueRef(converter->convertIntToString(convId));
-               /*
-               EventGetConversationIdPtr event(new EventGetConversationId());
-               event->setConversationMsgPtr(msg);
-               event->setForSynchronousCall();
-               ReqReceiverMessageSingleton::Instance().getConversationId(event);
-
-               convId = event->getConversationId();
-               // TODO messageIDref string size 0 => return NULL
-               return converter->toJSValueRef(convId);
-               */
        }
        Catch(WrtDeviceApis::Commons::ConversionException) {
                LogError("Error on conversion");
@@ -1757,8 +1785,8 @@ JSValueRef JSMessage::getInResponseTo(JSContextRef context,
 
                if (msg->getMessageType() != EMAIL)
                {
-                       LogDebug("not EMAIL type");
-                       return JSValueMakeNull(context);
+                       LogDebug("not EMAIL type return empty string");
+                       return converter->toJSValueRef("");
                }
 
                IEmailPtr email = MessageFactory::convertToEmail(msg);
@@ -1766,17 +1794,11 @@ JSValueRef JSMessage::getInResponseTo(JSContextRef context,
 
                LogDebug("msg.getConvId()=" << msg->getConvId());
                convId = msg->getConvId();
-               /*
-               EventGetConversationIdPtr event(new EventGetConversationId());
-               event->setConversationMsgPtr(msg);
-               event->setForSynchronousCall();
-               ReqReceiverMessageSingleton::Instance().getConversationId(event);
-               convId = event->getConversationId();
-               */
+
                if (convId == msgId)
                {
-                       LogDebug("Not forwared and replied, return NULL");
-                       return JSValueMakeNull(context);
+                       LogDebug("Not forwared and replied, return empty string");
+                       return converter->toJSValueRef("");
                }
 
                return converter->toJSValueRef(converter->convertIntToString(convId));
@@ -1870,7 +1892,7 @@ JSValueRef JSMessage::hasAttachment(JSContextRef context,
                }
                else
                {
-                       return JSValueMakeNull(context);
+                       hasAttachmentFlag = false;
                }
                return converter->toJSValueRef(hasAttachmentFlag);
 
index 0db13c9..bd2f2eb 100644 (file)
 // limitations under the License.
 //
 
+#include <iomanip>
 #include <dpl/log/log.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include "ConverterMessage.h"
 #include "JSMessageBody.h"
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
-#include "JSAttachmentArray.h"
-#endif
 #include <JSTizenExceptionFactory.h>
 #include <JSTizenException.h>
 #include "MessagingErrorMsg.h"
@@ -65,9 +63,6 @@ JSStaticValue JSMessageBody::m_property[] = {
     { "loaded", JSMessageBody::getLoadedStatus, NULL, kJSPropertyAttributeReadOnly },
     { "plainBody", JSMessageBody::getPlainBody, JSMessageBody::setPlainBody, kJSPropertyAttributeNone },
     { "htmlBody", JSMessageBody::getHtmlBody, JSMessageBody::setHtmlBody, kJSPropertyAttributeNone },
-#if 0 // MESSAGING ATTACHMENT IS BLOCKED
-    { "inlineAttachments", NULL, NULL, kJSPropertyAttributeReadOnly },
-#endif
     { "inlineAttachments", JSMessageBody::getAttachments, JSMessageBody::setAttachments, kJSPropertyAttributeNone },
     { 0, 0, 0, 0 }
 };
@@ -143,7 +138,7 @@ JSValueRef JSMessageBody::getMessageID(JSContextRef context,
                LogDebug("msg->getMessageStatus()=" << msg->getMessageStatus());
                if((id.size() == 0) && msg->getMessageStatus() == MESSAGE_STATUS_CREATED)
                {
-                       return JSValueMakeNull(context);
+                       return converter->toJSValueRef("");
                }
                return converter->toJSValueRef(id);
     }
@@ -167,12 +162,18 @@ JSValueRef JSMessageBody::getLoadedStatus(JSContextRef context,
          
          if (msg->getMessageType() == EMAIL)
          {
-               //IEmailPtr email = DPL::StaticPointerCast<Api::IEmailPtr>(MessageFactory::convertToEmail(msg));
                IEmailPtr email = MessageFactory::convertToEmail(msg);
                return converter.toJSValueRef(email->isBodyDownloaded() > 0 ? true : false);
          }
          else
          {
+               std::string id = msg->getId();
+               LogDebug("msgId=" << id);
+               LogDebug("msg->getMessageStatus()=" << msg->getMessageStatus());
+               if((id.size() == 0) && msg->getMessageStatus() == MESSAGE_STATUS_CREATED)
+               {
+                       return converter.toJSValueRef(false);
+               }
                return converter.toJSValueRef(true);
          }
          
@@ -189,30 +190,27 @@ JSValueRef JSMessageBody::getPlainBody(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
         JSValueRef* exception)
-{      
-    LogDebug("getPlainBody");
+{
+       LogDebug("getPlainBody");
 
-    Try
-    {          
-               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
                IMessagePtr msg = getMessage(context, object);
                std::string body = msg->getBody();
                LogDebug("getPlainBody plainBody" << body );
                return converter.toJSValueRef(body);
-    }
-    Catch(WrtDeviceApis::Commons::ConversionException) {
-        LogError("Error on conversion");
-         return JSTizenExceptionFactory::postException(context, exception, 
-                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-
-    }
-    Catch(WrtDeviceApis::Commons::NullPointerException) {
-        LogError("Error on conversion");
-        return JSTizenExceptionFactory::postException(context, exception, 
-                       JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-
-    }
-//    return JSValueMakeUndefined(context);
+       }
+       Catch(WrtDeviceApis::Commons::ConversionException) {
+               LogError("Error on conversion");
+               return JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+       }
+       Catch(WrtDeviceApis::Commons::NullPointerException) {
+               LogError("Error on conversion");
+               return JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+       }
 }
 
 bool JSMessageBody::setPlainBody(JSContextRef context,
@@ -221,34 +219,32 @@ bool JSMessageBody::setPlainBody(JSContextRef context,
         JSValueRef value,
         JSValueRef* exception)
 {
-
     LogDebug("setPlainBody");
-
-    Try
-    {
-          WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-        IMessagePtr msg = getMessage(context, object);
-        std::string body = converter.toString(value);
-        msg->setBody(body);
-         LogDebug("setPlainBody plainBody" << body );
-        return true;
-    }
-    Catch(WrtDeviceApis::Commons::ConversionException) {
-        LogError("Error on conversion");
-          return JSTizenExceptionFactory::postException(context, exception, 
-                         JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-    }
-    Catch(WrtDeviceApis::Commons::NullPointerException) {
-        LogError("Error on pointer, null value");
-        return JSTizenExceptionFactory::postException(context, exception, 
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+               IMessagePtr msg = getMessage(context, object);
+               std::string body = converter.toString(value);
+               msg->setBody(body);
+               LogDebug("setPlainBody plainBody" << body );
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::ConversionException) {
+               LogError("Error on conversion");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+       }
+       Catch(WrtDeviceApis::Commons::NullPointerException) {
+               LogError("Error on pointer, null value");
+               return JSTizenExceptionFactory::postException(context, exception, 
                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-    }
-    Catch(WrtDeviceApis::Commons::PlatformException) {
-        LogError("Platform execution");
-        return JSTizenExceptionFactory::postException(context, exception, 
+       }
+       Catch(WrtDeviceApis::Commons::PlatformException) {
+               LogError("Platform execution");
+               return JSTizenExceptionFactory::postException(context, exception, 
                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-    }
-    return false;
+       }
+       return false;
 }
 
 JSValueRef JSMessageBody::getHtmlBody(JSContextRef context,
@@ -256,44 +252,39 @@ JSValueRef JSMessageBody::getHtmlBody(JSContextRef context,
        JSStringRef propertyName,
        JSValueRef* exception)
 {
-    
        LogDebug("getHtmlBody");
-    Try
-    {          
-               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+       Try
+       {               
+               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
                IMessagePtr msg = getMessage(context, object);
 
-             LogDebug("message Type : " << msg->getMessageType() );
+               LogDebug("message Type : " << msg->getMessageType() );
                if (msg->getMessageType() == EMAIL)
-                 {
+               {
                        IEmailPtr email = MessageFactory::convertToEmail(msg);
-
-                LogDebug("Html Body : " << email->getHtmlBody() );
+                       LogDebug("Html Body : " << email->getHtmlBody() );
                        return converter.toJSValueRef(email->getHtmlBody());
-                 }
-                 else
-                 {
-                        return JSValueMakeNull(context);
-                 }
-    }
-    Catch(WrtDeviceApis::Commons::ConversionException) {
-        LogError("Error on conversion");
-          return JSTizenExceptionFactory::postException(context, exception, 
-                         JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-    }
-    Catch(WrtDeviceApis::Commons::NullPointerException) {
-        LogError("Error on pointer, null value");
-        return JSTizenExceptionFactory::postException(context, exception, 
+               }
+               else
+               {
+                       return converter.toJSValueRef("");
+               }
+       }
+       Catch(WrtDeviceApis::Commons::ConversionException) {
+               LogError("Error on conversion");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+       }
+       Catch(WrtDeviceApis::Commons::NullPointerException) {
+               LogError("Error on pointer, null value");
+               return JSTizenExceptionFactory::postException(context, exception, 
                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-    }
-    Catch(WrtDeviceApis::Commons::PlatformException) {
-        LogError("Platform execution");
-        return JSTizenExceptionFactory::postException(context, exception, 
+       }
+       Catch(WrtDeviceApis::Commons::PlatformException) {
+               LogError("Platform execution");
+               return JSTizenExceptionFactory::postException(context, exception, 
                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-    }
-
-       
-//    return JSValueMakeUndefined(context);
+       }
 }
 
 bool JSMessageBody::setHtmlBody(JSContextRef context,
@@ -302,46 +293,46 @@ bool JSMessageBody::setHtmlBody(JSContextRef context,
        JSValueRef value,
        JSValueRef* exception)
 {
-
        LogDebug("setHtmlBody");
 
        Try
-          {
-                 WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-                 IMessagePtr msg = getMessage(context, object);
-                 
-                 if (msg->getMessageType() == EMAIL)
-                 {
+       {
+               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+               IMessagePtr msg = getMessage(context, object);
+
+               if (msg->getMessageType() == EMAIL)
+               {
                        IEmailPtr email = MessageFactory::convertToEmail(msg);
-                       std::string body = converter.toString(value);
+                       std::string body = converter.toString(value);
                        LogDebug("input String : " << body);
                        email->setHtmlBody(body);
                        return true;
-                 }
-                 else
-                 {
-                        LogError("html body is for Email only.");
-                        return JSTizenExceptionFactory::postException(context, exception, 
-                                 JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED);
-                 }
-          }
-           Catch(WrtDeviceApis::Commons::ConversionException) {
-               LogError("Error on conversion");
-                  return JSTizenExceptionFactory::postException(context, exception, 
-                                 JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-           }
-           Catch(WrtDeviceApis::Commons::NullPointerException) {
-               LogError("Error on pointer, null value");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-           }
-           Catch(WrtDeviceApis::Commons::PlatformException) {
-               LogError("Platform execution");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-           }
-
-          return false;
+               }
+               else
+               {
+                       LogError("html body is for Email only.");
+                       return true;
+//                     return JSTizenExceptionFactory::postException(context, exception, 
+//                                     JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED);
+               }
+       }
+       Catch(WrtDeviceApis::Commons::ConversionException) {
+               LogError("Error on conversion");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+       }
+       Catch(WrtDeviceApis::Commons::NullPointerException) {
+               LogError("Error on pointer, null value");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+       }
+       Catch(WrtDeviceApis::Commons::PlatformException) {
+               LogError("Platform execution");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+       }
+
+       return false;
 }
 
 
@@ -391,7 +382,15 @@ JSValueRef JSMessageBody::getAttachments(JSContextRef context,
                        }
                        case SMS:
                        case MMS:
-                               return JSValueMakeNull(context);
+                       {
+                               JSObjectRef arrayValue = JSCreateArrayObject(context, 0, NULL);
+                               if (NULL == arrayValue)
+                               {
+                                       LogError("Could not create js array object");
+                                       return JSValueMakeUndefined(context);
+                               }
+                               return arrayValue;
+                       }
 
                        default:
                                LogError("not supported message type");
@@ -401,12 +400,12 @@ JSValueRef JSMessageBody::getAttachments(JSContextRef context,
        Catch(WrtDeviceApis::Commons::ConversionException) {
                LogError("Error on conversion");
                return JSTizenExceptionFactory::postException(context, exception,
-               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
        }
        Catch(WrtDeviceApis::Commons::NullPointerException) {
                LogError("Error on pointer, null value");
                return JSTizenExceptionFactory::postException(context, exception,
-               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
        }
 }
 
@@ -470,11 +469,12 @@ bool JSMessageBody::setAttachments(JSContextRef context,
                                        {
                                                IEmailPtr email = MessageFactory::convertToEmail(msg);
                                                email->setInlineAttachments(inlineAttachments);
-                                       break;
+                                               break;
                                        }
                                        default:
                                                LogError("not supported message type");
-                                               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+//                                             Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+                                       return true;
                                }
                                return true;
                        }
@@ -518,14 +518,12 @@ IMessagePtr JSMessageBody::getMessage(JSContextRef context,
 IMessagePtr JSMessageBody::getMessage(JSContextRef context,
         JSObjectRef object)
 {
-    // private object of thisObject
     return getPrivate(object)->getObject();
 }
 
 JSMessageBodyPrivate* JSMessageBody::getPrivate(JSObjectRef thisObject)
 {
-    JSMessageBodyPrivate* thisPrivate =
-        static_cast<JSMessageBodyPrivate*>(JSObjectGetPrivate(thisObject));
+       JSMessageBodyPrivate* thisPrivate = static_cast<JSMessageBodyPrivate*>(JSObjectGetPrivate(thisObject));
     if (!thisPrivate) {
         LogError("no private");
         Throw(WrtDeviceApis::Commons::NullPointerException);
index bdff79c..f715777 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "MessagingErrorMsg.h"
 #include "MessageAsyncCallbackManager.h"
+#include "MessageFilterConverter.h"
 #include "plugin_config.h"
 
 
@@ -356,7 +357,8 @@ namespace Messaging {
                {
                        EventQueryMessagesPtr event(new EventQueryMessages());
                        
-                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+                       MessageMessagesFilterConverterFactory::ConverterType filterConverter =
+                                       MessageMessagesFilterConverterFactory::getConverter(context);
 
                        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
 
@@ -858,7 +860,8 @@ namespace Messaging {
                {
                        EventQueryConversationsPtr event(new EventQueryConversations());
                        
-                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+                       MessageConversationsFilterConverterFactory::ConverterType filterConverter =
+                                       MessageConversationsFilterConverterFactory::getConverter(context);
 
                        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
 
@@ -1178,7 +1181,8 @@ namespace Messaging {
                {
                        EventQueryFoldersPtr event(new EventQueryFolders());
                        
-                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+                       MessageFoldersFilterConverterFactory::ConverterType filterConverter =
+                                       MessageFoldersFilterConverterFactory::getConverter(context);
 
                        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
 
@@ -1324,7 +1328,8 @@ namespace Messaging {
 
                Try
                {
-                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+                       MessageMessagesChangeFilterConverterFactory::ConverterType filterConverter =
+                                       MessageMessagesChangeFilterConverterFactory::getConverter(context);
 
                        JSValueRef onSuccessForCbm = NULL;
 
@@ -1477,7 +1482,8 @@ namespace Messaging {
 
                Try
                {
-                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+                       MessageConversationsFilterConverterFactory::ConverterType filterConverter =
+                                       MessageConversationsFilterConverterFactory::getConverter(context);
 
                        JSValueRef onSuccessForCbm = NULL;
 
@@ -1633,7 +1639,8 @@ namespace Messaging {
                Try
                {
 
-                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+                       MessageFoldersFilterConverterFactory::ConverterType filterConverter =
+                                       MessageFoldersFilterConverterFactory::getConverter(context);
 
                        JSValueRef onSuccessForCbm = NULL;
 
index 38dd4e6..27a898a 100755 (executable)
@@ -111,8 +111,8 @@ RecipientsPtr JSRecipientArray::getRecipients(JSContextRef context,
     JSRecipientArrayPrivate* priv =
         static_cast<JSRecipientArrayPrivate*>(JSObjectGetPrivate(object));
     if (!priv) {
-        ThrowMsg(WrtDeviceApis::Commons::NullPointerException,
-                 "Array contains no private object");
+        LogError("Array contains no private object");
+        ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Array contains no private object");
     }
     return priv->getObject();
 }
index 54ffbd6..521e8a3 100644 (file)
@@ -43,7 +43,6 @@ namespace DeviceAPI {
 namespace Messaging {
 
 using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
 
 MailSender& MailSender::getInstance()
 {
index 248b40d..d94752d 100644 (file)
@@ -48,7 +48,6 @@ namespace DeviceAPI {
 namespace Messaging {
 
 using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
 
 MailSync& MailSync::getInstance()
 {
@@ -541,18 +540,21 @@ void MailSync::OnEventReceived(const DBus::MessageEvent& event)
                                {
                                        EventMessagingServicePtr event = messagingService->getEventFromHandle(handle);
                                        // get event using handle from m_opRequests;
-                                       if ( status == NOTI_DOWNLOAD_FINISH )
+                                       if (event)
                                        {
-                                               LogDebug("Sync Success");
-                                               requestReceiver->ManualAnswer(event);
-                                               m_SyncRequests.erase( handle );
-                                       }
-                                       else if ( status == NOTI_DOWNLOAD_FAIL )
-                                       {
-                                               LogDebug("Sync Fail");
-                                               event->setExceptionCode( WrtDeviceApis::Commons::ExceptionCodes::UnknownException );
-                                               requestReceiver->ManualAnswer(event);
-                                               m_SyncRequests.erase( handle );
+                                               if ( status == NOTI_DOWNLOAD_FINISH )
+                                               {
+                                                       LogDebug("Sync Success");
+                                                       requestReceiver->ManualAnswer(event);
+                                                       m_SyncRequests.erase( handle );
+                                               }
+                                               else if ( status == NOTI_DOWNLOAD_FAIL )
+                                               {
+                                                       LogDebug("Sync Fail");
+                                                       event->setExceptionCode( WrtDeviceApis::Commons::ExceptionCodes::UnknownException );
+                                                       requestReceiver->ManualAnswer(event);
+                                                       m_SyncRequests.erase( handle );
+                                               }
                                        }
                                }
                                else
@@ -570,18 +572,21 @@ void MailSync::OnEventReceived(const DBus::MessageEvent& event)
                                if ( messagingService && requestReceiver)
                                {
                                        EventMessagingServicePtr event = messagingService->getEventFromHandle(handle);
-                                       if ( status == NOTI_DOWNLOAD_FINISH )
+                                       if (event)
                                        {
-                                               LogDebug("Sync Success");
-                                                       requestReceiver->ManualAnswer(event);
-                                               m_SyncRequests.erase( handle );
-                                       }
-                                       else if ( status == NOTI_DOWNLOAD_FAIL )
-                                       {
-                                               LogDebug("Sync Fail");
-                                               event->setExceptionCode( WrtDeviceApis::Commons::ExceptionCodes::UnknownException );
-                                               requestReceiver->ManualAnswer(event);
-                                               m_SyncRequests.erase( handle );
+                                               if ( status == NOTI_DOWNLOAD_FINISH )
+                                               {
+                                                       LogDebug("Sync Success");
+                                               requestReceiver->ManualAnswer(event);
+                                                       m_SyncRequests.erase( handle );
+                                               }
+                                               else if ( status == NOTI_DOWNLOAD_FAIL )
+                                               {
+                                                       LogDebug("Sync Fail");
+                                               event->setExceptionCode( WrtDeviceApis::Commons::ExceptionCodes::UnknownException );
+                                                       requestReceiver->ManualAnswer(event);
+                                                       m_SyncRequests.erase( handle );
+                                               }
                                        }
                                }
                                else
diff --git a/src/Messaging/MessageFilterConverter.cpp b/src/Messaging/MessageFilterConverter.cpp
new file mode 100644 (file)
index 0000000..1ca7860
--- /dev/null
@@ -0,0 +1,218 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file        MessageFilterConverter.cpp
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @description        Reference from CalendarConverter.cpp
+ */
+
+#include "MessageFilterConverter.h"
+
+#include <dpl/log/log.h>
+
+namespace DeviceAPI {
+namespace Messaging {
+
+using namespace std;
+using namespace DeviceAPI::Tizen;
+
+#define ATTRIBUTE_ACCOUNT_ID        "serviceId"
+#define ATTRIBUTE_ATTACHMENT        "hasAttachment"
+#define ATTRIBUTE_BCC               "bcc"
+#define ATTRIBUTE_BODY              "body.plainBody"
+#define ATTRIBUTE_CC                "cc"
+#define ATTRIBUTE_CONTENT_TYPE      "contentType"
+#define ATTRIBUTE_CONVERSATION_ID   "conversationId"
+#define ATTRIBUTE_FOLDER_ID         "folderId"
+#define ATTRIBUTE_FOLDERPATH        "path"
+#define ATTRIBUTE_FROM              "from"
+#define ATTRIBUTE_HAS_ATTACHMENT    "hasAttachment"
+#define ATTRIBUTE_ID                "id"
+#define ATTRIBUTE_IS_READ           "isRead"
+#define ATTRIBUTE_IS_RESPONSE_TO    "isResponseTo"
+#define ATTRIBUTE_LAST_MESSAGE_ID   "lastMessageId"
+#define ATTRIBUTE_MESSAGE_COUNT     "messageCount"
+#define ATTRIBUTE_MESSAGE_STATUS    "messageStatus"
+#define ATTRIBUTE_NAME              "name"
+#define ATTRIBUTE_PARENT_ID         "parentId"
+#define ATTRIBUTE_PATH              "path"
+#define ATTRIBUTE_PREVIEW           "preview"
+#define ATTRIBUTE_PRIORITY          "isHighPriority"
+#define ATTRIBUTE_SERVICE_ID        "serviceId"
+#define ATTRIBUTE_SUBJECT           "subject"
+#define ATTRIBUTE_SYNCHRONIZABLE    "synchronizable"
+#define ATTRIBUTE_TIMESTAMP         "timestamp"
+#define ATTRIBUTE_TO                "to"
+#define ATTRIBUTE_TYPE              "type"
+#define ATTRIBUTE_UNREAD_MESSAGES   "unreadMessages"
+
+static PropertyStructArray propertiesMessages =
+{
+               { ATTRIBUTE_ID,                 PrimitiveType_String },
+               { ATTRIBUTE_SERVICE_ID,         PrimitiveType_String },
+               { ATTRIBUTE_TYPE,               PrimitiveType_String },
+               { ATTRIBUTE_FOLDER_ID,          PrimitiveType_String },
+               { ATTRIBUTE_TIMESTAMP,          PrimitiveType_Time },
+               { ATTRIBUTE_FROM,               PrimitiveType_String },
+               { ATTRIBUTE_TO,                 PrimitiveType_String },
+               { ATTRIBUTE_CC,                 PrimitiveType_String },
+               { ATTRIBUTE_BCC,                PrimitiveType_String },
+               { ATTRIBUTE_BODY,               PrimitiveType_String },
+               { ATTRIBUTE_IS_READ,            PrimitiveType_Boolean },
+               { ATTRIBUTE_PRIORITY,           PrimitiveType_Boolean },
+               { ATTRIBUTE_SUBJECT,            PrimitiveType_String },
+               { ATTRIBUTE_ATTACHMENT,         PrimitiveType_Boolean },
+               { 0,                            PrimitiveType_NoType }
+};
+
+static PropertyStructArray propertiesConversations =
+{
+               { ATTRIBUTE_ID,                 PrimitiveType_String },
+               { ATTRIBUTE_TYPE,               PrimitiveType_String },
+               { ATTRIBUTE_TIMESTAMP,          PrimitiveType_Time },
+               { ATTRIBUTE_MESSAGE_COUNT,      PrimitiveType_ULong },
+               { ATTRIBUTE_UNREAD_MESSAGES,    PrimitiveType_ULong },
+               { ATTRIBUTE_PREVIEW,            PrimitiveType_String },
+               { ATTRIBUTE_FROM,               PrimitiveType_String },
+               { ATTRIBUTE_TO,                 PrimitiveType_String },
+               { 0,                            PrimitiveType_NoType }
+};
+
+static PropertyStructArray propertiesFolders =
+{
+               { ATTRIBUTE_ACCOUNT_ID,         PrimitiveType_String },
+               { ATTRIBUTE_FOLDERPATH,         PrimitiveType_String },
+               { 0,                            PrimitiveType_NoType }
+};
+
+static PropertyStructArray propertiesMessagesChange =
+{
+               { ATTRIBUTE_SERVICE_ID,         PrimitiveType_String },
+               { ATTRIBUTE_CONVERSATION_ID,    PrimitiveType_String },
+               { ATTRIBUTE_FOLDER_ID,          PrimitiveType_String },
+               { ATTRIBUTE_TYPE,               PrimitiveType_String },
+               { ATTRIBUTE_TIMESTAMP,          PrimitiveType_Time },
+               { ATTRIBUTE_FROM,               PrimitiveType_String },
+               { ATTRIBUTE_TO,                 PrimitiveType_String },
+               { ATTRIBUTE_CC,                 PrimitiveType_String },
+               { ATTRIBUTE_BCC,                PrimitiveType_String },
+               { ATTRIBUTE_BODY,               PrimitiveType_String },
+               { ATTRIBUTE_IS_READ,            PrimitiveType_Boolean },
+               { ATTRIBUTE_HAS_ATTACHMENT,     PrimitiveType_Boolean },
+               { ATTRIBUTE_PRIORITY,           PrimitiveType_Boolean },
+               { ATTRIBUTE_SUBJECT,            PrimitiveType_String },
+               { ATTRIBUTE_IS_RESPONSE_TO,     PrimitiveType_String },
+               { ATTRIBUTE_MESSAGE_STATUS,     PrimitiveType_String },
+               { 0,                            PrimitiveType_NoType }
+};
+
+static PropertyStructArray propertiesConversationsChange =
+{
+               { ATTRIBUTE_ID,                 PrimitiveType_String },
+               { ATTRIBUTE_TYPE,               PrimitiveType_String },
+               { ATTRIBUTE_TIMESTAMP,          PrimitiveType_Time },
+               { ATTRIBUTE_MESSAGE_COUNT,      PrimitiveType_ULong },
+               { ATTRIBUTE_UNREAD_MESSAGES,    PrimitiveType_ULong },
+               { ATTRIBUTE_PREVIEW,            PrimitiveType_String },
+               { ATTRIBUTE_SUBJECT,            PrimitiveType_String },
+               { ATTRIBUTE_IS_READ,            PrimitiveType_Boolean },
+               { ATTRIBUTE_FROM,               PrimitiveType_String },
+               { ATTRIBUTE_TO,                 PrimitiveType_String },
+               { ATTRIBUTE_CC,                 PrimitiveType_String },
+               { ATTRIBUTE_BCC,                PrimitiveType_String },
+               { ATTRIBUTE_LAST_MESSAGE_ID,    PrimitiveType_String },
+               { 0,                            PrimitiveType_NoType }
+};
+
+static PropertyStructArray propertiesFoldersChange =
+{
+               { ATTRIBUTE_ID,                 PrimitiveType_String },
+               { ATTRIBUTE_PARENT_ID,          PrimitiveType_String },
+               { ATTRIBUTE_ACCOUNT_ID,         PrimitiveType_String },
+               { ATTRIBUTE_CONTENT_TYPE,       PrimitiveType_String },
+               { ATTRIBUTE_NAME,               PrimitiveType_String },
+               { ATTRIBUTE_PATH,               PrimitiveType_String },
+               { ATTRIBUTE_TYPE,               PrimitiveType_String },
+               { ATTRIBUTE_SYNCHRONIZABLE,     PrimitiveType_Boolean },
+               { 0,                            PrimitiveType_NoType }
+};
+
+MessageMessagesFilterConverter::MessageMessagesFilterConverter(JSContextRef context) :
+               FilterConverter(context, propertiesMessages, false)
+{
+}
+
+MessageMessagesFilterConverter::~MessageMessagesFilterConverter()
+{
+       LogDebug("entered");
+}
+
+MessageConversationsFilterConverter::MessageConversationsFilterConverter(JSContextRef context) :
+               FilterConverter(context, propertiesConversations, false)
+{
+}
+
+MessageConversationsFilterConverter::~MessageConversationsFilterConverter()
+{
+       LogDebug("entered");
+}
+
+MessageFoldersFilterConverter::MessageFoldersFilterConverter(JSContextRef context) :
+               FilterConverter(context, propertiesFolders, false)
+{
+}
+
+MessageFoldersFilterConverter::~MessageFoldersFilterConverter()
+{
+       LogDebug("entered");
+}
+
+MessageMessagesChangeFilterConverter::MessageMessagesChangeFilterConverter(JSContextRef context) :
+               FilterConverter(context, propertiesMessagesChange, false)
+{
+}
+
+MessageMessagesChangeFilterConverter::~MessageMessagesChangeFilterConverter()
+{
+       LogDebug("entered");
+}
+
+MessageConversationsChangeFilterConverter::MessageConversationsChangeFilterConverter(JSContextRef context) :
+               FilterConverter(context, propertiesConversationsChange, false)
+{
+}
+
+MessageConversationsChangeFilterConverter::~MessageConversationsChangeFilterConverter()
+{
+       LogDebug("entered");
+}
+
+MessageFoldersChangeFilterConverter::MessageFoldersChangeFilterConverter(JSContextRef context) :
+               FilterConverter(context, propertiesFoldersChange, false)
+{
+}
+
+MessageFoldersChangeFilterConverter::~MessageFoldersChangeFilterConverter()
+{
+       LogDebug("entered");
+}
+
+} // Messaging
+} // DeviceAPI
+
diff --git a/src/Messaging/MessageFilterConverter.h b/src/Messaging/MessageFilterConverter.h
new file mode 100644 (file)
index 0000000..46a7d76
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file        MessageFilterConverter.h
+ * @version     0.1
+ * @description        Reference from CalendarConverter.h
+ */
+
+#ifndef _TIZEN_MESSAGE_FILTER_CONVERTER_H_
+#define _TIZEN_MESSAGE_FILTER_CONVERTER_H_
+
+#include <set>
+#include <string>
+#include <FilterConverter.h>
+
+namespace DeviceAPI {
+namespace Messaging {
+
+class MessageMessagesFilterConverter : public DeviceAPI::Tizen::FilterConverter
+{
+public:
+       explicit MessageMessagesFilterConverter(JSContextRef context);
+       virtual ~MessageMessagesFilterConverter();
+};
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<MessageMessagesFilterConverter> MessageMessagesFilterConverterFactory;
+
+class MessageConversationsFilterConverter : public DeviceAPI::Tizen::FilterConverter
+{
+public:
+       explicit MessageConversationsFilterConverter(JSContextRef context);
+       virtual ~MessageConversationsFilterConverter();
+};
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<MessageConversationsFilterConverter> MessageConversationsFilterConverterFactory;
+
+class MessageFoldersFilterConverter : public DeviceAPI::Tizen::FilterConverter
+{
+public:
+       explicit MessageFoldersFilterConverter(JSContextRef context);
+       virtual ~MessageFoldersFilterConverter();
+};
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<MessageFoldersFilterConverter> MessageFoldersFilterConverterFactory;
+
+class MessageMessagesChangeFilterConverter : public DeviceAPI::Tizen::FilterConverter
+{
+public:
+       explicit MessageMessagesChangeFilterConverter(JSContextRef context);
+       virtual ~MessageMessagesChangeFilterConverter();
+};
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<MessageMessagesChangeFilterConverter> MessageMessagesChangeFilterConverterFactory;
+
+class MessageConversationsChangeFilterConverter : public DeviceAPI::Tizen::FilterConverter
+{
+public:
+       explicit MessageConversationsChangeFilterConverter(JSContextRef context);
+       virtual ~MessageConversationsChangeFilterConverter();
+};
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<MessageConversationsChangeFilterConverter> MessageConversationsChangeFilterConverterFactory;
+
+class MessageFoldersChangeFilterConverter : public DeviceAPI::Tizen::FilterConverter
+{
+public:
+       explicit MessageFoldersChangeFilterConverter(JSContextRef context);
+       virtual ~MessageFoldersChangeFilterConverter();
+};
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<MessageFoldersChangeFilterConverter> MessageFoldersChangeFilterConverterFactory;
+
+} // Messaging
+} // DeviceAPI
+
+#endif // _TIZEN_MESSAGE_FILTER_CONVERTER_H_
+
index 4878d96..13e9ecf 100755 (executable)
@@ -21,8 +21,6 @@
 #include <dpl/log/log.h>
 #include "log.h"
 
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace DeviceAPI::Tizen;
 
 namespace DeviceAPI {
index b0f6244..756b72a 100755 (executable)
@@ -27,6 +27,7 @@
 #include <msg_storage_types.h>
 #include <sstream>
 #include <time.h>
+#include <iomanip>
 
 #include <dpl/log/log.h>
 
@@ -424,14 +425,14 @@ namespace DeviceAPI {
                        LogDebug("<<< value:[" << value->toString() << "]");
 
                        if (!value->isNullOrUndefined()) {
-                               if( DeviceAPI::Tizen::PrimitiveType_Time==value->getType() ) {
-                                       LogDebug("<<<initialValue->getType()[" << value->getType() <<"]");                                      
-                                       tm date = value->getDateTm();
+                               if( value->isType(DeviceAPI::Tizen::PrimitiveType_Time) ) {
+                                       LogDebug("<<<initialValue->getType()[PrimitiveType_Time]");
+                                       tm date = *value->getDateTm();
                                        initialValueStr = toDateDbStr(date);
                                        LogDebug("<<<valueStr[" << initialValueStr <<"]");
                                }
                                else {
-                                       LogError("initialValue->getType() : [" << value->getType() << "]");                                     
+                                       LogError("initialValue->getType()");
                                        ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid value Type");
                                }                               
                        }
@@ -472,20 +473,20 @@ namespace DeviceAPI {
                        std::string initialValueStr;
                        LogDebug("<<< value:[" << value->toString() << "]");
 
-                       if(value->getType() != PrimitiveType_Time){
+                       if(!value->isType(PrimitiveType_Time)){
                                LogError("[ERROR]>> invalid type");
                                return NULL;
                        }
                                
                        if (!value->isNullOrUndefined()) {
-                               if( DeviceAPI::Tizen::PrimitiveType_Time==value->getType() ) {
-                                       LogDebug("<<<initialValue->getType()[" << value->getType() <<"]");                                      
-                                       tm date = value->getDateTm();
+                               if( value->isType(DeviceAPI::Tizen::PrimitiveType_Time) ) {
+                                       LogDebug("<<<initialValue->getType()[PrimitiveType_Time]");
+                                       tm date = *value->getDateTm();
                                        initialValueStr = toDateDbStr(date);
                                        LogDebug("<<<valueStr[" << initialValueStr <<"]");
                                }
                                else {
-                                       LogError("initialValue->getType() : [" << value->getType() << "]");                                     
+                                       LogError("initialValue->getType()");
                                        ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid value Type");
                                }                               
                        }
@@ -790,25 +791,25 @@ namespace DeviceAPI {
                        if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_TIMESTAMP)==0){
 
                                if (!initialValue->isNullOrUndefined()) {
-                                       if( DeviceAPI::Tizen::PrimitiveType_Time==initialValue->getType() ) {
-                                               LogDebug("<<<initialValue->getType()[" << initialValue->getType() <<"]");                                       
-                                               tm date = initialValue->getDateTm();
+                                       if( initialValue->isType(DeviceAPI::Tizen::PrimitiveType_Time) ) {
+                                               LogDebug("<<<initialValue->getType()[PrimitiveType_Time]");
+                                               tm date = *initialValue->getDateTm();
                                                initialValueStr = toDateDbStr(date);
                                                LogDebug("<<<valueStr[" << initialValueStr <<"]");
                                        }
                                        else {
-                                               LogError("initialValue->getType() : [" << initialValue->getType() << "]");                                      
+                                               LogError("initialValue->getType()");
                                                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid initialValue Type");
                                        }
                                }
                                
                                if (!endValue->isNullOrUndefined()) {
-                                       if( DeviceAPI::Tizen::PrimitiveType_Time==endValue->getType() ) {
-                                               LogDebug("<<<initialValue->getType()[" << endValue->getType() <<"]");                                   
-                                               tm date = endValue->getDateTm();
+                                       if( endValue->isType(DeviceAPI::Tizen::PrimitiveType_Time) ) {
+                                               LogDebug("<<<initialValue->getType()[PrimitiveType_Time]");
+                                               tm date = *endValue->getDateTm();
                                                endValueStr = toDateDbStr(date);
                                        } else {
-                                               LogError("endValue->getType() : [" << endValue->getType() << "]");                                      
+                                               LogError("endValue->getType()");
                                                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid endValue Type");
                                        }
                                }
index ac6e370..ec886ac 100755 (executable)
@@ -365,11 +365,11 @@ std::string Messaging::generateFilterSql(const DeviceAPI::Tizen::FilterPtr& filt
                std::string tempString = "";
 //             MSG_LIST_S message_list = {0, NULL};
                msg_struct_list_s message_list = {0,};
+               MessageStorageReader reader;
 
                Try{
                        msg_error_t res = MSG_ERR_UNKNOWN;
 
-                       MessageStorageReader reader;
                        reader.MsgStoConnectDB();
                        res = reader.queryMessage(queryString, tempString, &message_list);
 
@@ -380,11 +380,11 @@ std::string Messaging::generateFilterSql(const DeviceAPI::Tizen::FilterPtr& filt
                        reader.MsgStoDisconnectDB();
 
                        retVal = createVectorFromeMessageList(message_list);
-                       msg_release_list_struct(&message_list);
+                       reader.msg_release_list_struct_private(&message_list);
                }Catch(WrtDeviceApis::Commons::PlatformException) {
                        LogError("Problem with message creation, cleaning");
                        if (message_list.nCount) {
-                               msg_release_list_struct(&message_list);
+                               reader.msg_release_list_struct_private(&message_list);
                        }
                        throw;
                }       //Catch
@@ -400,11 +400,11 @@ std::string Messaging::generateFilterSql(const DeviceAPI::Tizen::FilterPtr& filt
                vector<IMessagePtr> retVal;
 //             MSG_LIST_S message_list = {0, NULL};
                msg_struct_list_s message_list = {0,};
+               MessageStorageReader reader;
 
                Try{
                        msg_error_t res = MSG_ERR_UNKNOWN;
 
-                       MessageStorageReader reader;
                        reader.MsgStoConnectDB();
                        res = reader.queryMessage(queryString, orderLimitString, &message_list);
 
@@ -417,11 +417,11 @@ std::string Messaging::generateFilterSql(const DeviceAPI::Tizen::FilterPtr& filt
                        retVal = createVectorFromeMessageList(message_list);
                        LogDebug("<<< message_list.nCount:[" << message_list.nCount <<"]");                     
                        
-                       msg_release_list_struct(&message_list);
+                       reader.msg_release_list_struct_private(&message_list);
                }Catch(WrtDeviceApis::Commons::PlatformException) {
                        LogError("Problem with message creation, cleaning");
                        if (message_list.nCount) {
-                               msg_release_list_struct(&message_list);
+                               reader.msg_release_list_struct_private(&message_list);
                        }
                        throw;
                }       //Catch
@@ -452,7 +452,7 @@ vector<IConversationPtr> Messaging::querySmsMmsConversation(const std::string& s
 
        recVec = createVectorFromeThreadViewList(threadViewList);
 
-       msg_release_list_struct(&threadViewList);
+       reader.msg_release_list_struct_private(&threadViewList);
 
        LogDebug(">>>");
        return recVec;
index 5c7939c..c70eda2 100755 (executable)
@@ -20,8 +20,6 @@
 
 #include <dpl/log/log.h>
 
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace DeviceAPI::Tizen;
 
 namespace DeviceAPI {
index 8ed1b58..64c6e40 100755 (executable)
@@ -41,11 +41,11 @@ namespace DeviceAPI {
                                {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_ID.c_str(),                           DeviceAPI::Tizen::PrimitiveType_String},
                                {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TYPE.c_str(),             DeviceAPI::Tizen::PrimitiveType_String},
                                {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TIMESTAMP.c_str(), DeviceAPI::Tizen::PrimitiveType_Time},
-                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_MESSAGE_COUNT.c_str(),    DeviceAPI::Tizen::PrimitiveType_Number},
-                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_UNREAD_MESSAGES.c_str(),  DeviceAPI::Tizen::PrimitiveType_Number},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_MESSAGE_COUNT.c_str(),    DeviceAPI::Tizen::PrimitiveType_ULong},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_UNREAD_MESSAGES.c_str(),  DeviceAPI::Tizen::PrimitiveType_ULong},
                                {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_PREVIEW.c_str(),          DeviceAPI::Tizen::PrimitiveType_String},
                                {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_SUBJECT.c_str(),          DeviceAPI::Tizen::PrimitiveType_String},
-                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_IS_READ.c_str(),          DeviceAPI::Tizen::PrimitiveType_Number},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_IS_READ.c_str(),          DeviceAPI::Tizen::PrimitiveType_Boolean},
                                {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_FROM.c_str(),             DeviceAPI::Tizen::PrimitiveType_String},
                                {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TO.c_str(),               DeviceAPI::Tizen::PrimitiveType_String},
                                {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_CC.c_str(),               DeviceAPI::Tizen::PrimitiveType_String},
index f7ed163..3620e3f 100755 (executable)
@@ -589,24 +589,24 @@ namespace Messaging {
                        if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TIMESTAMP)==0){
 
                                if (!initialValue->isNullOrUndefined()) {
-                                       if( DeviceAPI::Tizen::PrimitiveType_Time==initialValue->getType() ) {
-                                               LogDebug("<<<initialValue->getType()[" << initialValue->getType() <<"]");                                       
-                                               startTime = initialValue->getDateTm();
+                                       if( initialValue->isType(DeviceAPI::Tizen::PrimitiveType_Time) ) {
+                                               LogDebug("<<<initialValue->getType()[PrimitiveType_Time]");
+                                               startTime = *initialValue->getDateTm();
                                                LogDebug("<<<valueStr[" << initialValueStr <<"]");
                                        }
                                        else {
-                                               LogError("initialValue->getType() : [" << initialValue->getType() << "]");                                      
+                                               LogError("initialValue->getType()");
                                                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid initialValue Type");
                                        }
                                }
                                
                                if (!endValue->isNullOrUndefined()) {
-                                       if( DeviceAPI::Tizen::PrimitiveType_Time==endValue->getType() ) {
-                                               LogDebug("<<<endValue->getType()[" << endValue->getType() <<"]");                                       
-                                               endTime= endValue->getDateTm();
+                                       if( endValue->isType(DeviceAPI::Tizen::PrimitiveType_Time) ) {
+                                               LogDebug("<<<endValue->getType()[PrimitiveType_Time]");
+                                               endTime= *endValue->getDateTm();
                                                LogDebug("<<<valueStr[" << endValueStr <<"]");                                  
                                        } else {
-                                               LogError("endValue->getType() : [" << endValue->getType() << "]");                                      
+                                               LogError("endValue->getType()");
                                                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid endValue Type");
                                        }
                                }
index 095e6f6..9741abd 100755 (executable)
@@ -20,8 +20,6 @@
 
 #include <dpl/log/log.h>
 
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace DeviceAPI::Tizen;
 
 namespace DeviceAPI {
index 739e5c2..53e4b0f 100755 (executable)
@@ -40,7 +40,7 @@ namespace DeviceAPI {
                                {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_NAME.c_str(),                            DeviceAPI::Tizen::PrimitiveType_String},
                                {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_PATH.c_str(),                                    DeviceAPI::Tizen::PrimitiveType_String},
                                {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_TYPE.c_str(),                                    DeviceAPI::Tizen::PrimitiveType_String},
-                               {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_SYNCHRONIZABLE.c_str(),          DeviceAPI::Tizen::PrimitiveType_Number},
+                               {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_SYNCHRONIZABLE.c_str(),          DeviceAPI::Tizen::PrimitiveType_Boolean},
                                {0,                  DeviceAPI::Tizen::PrimitiveType_NoType}
                };
 
index 34ac3c7..64c76d3 100755 (executable)
@@ -20,8 +20,6 @@
 
 #include <dpl/log/log.h>
 
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace DeviceAPI::Tizen;
 
 namespace DeviceAPI {
index d4b9af7..b2ccf23 100755 (executable)
@@ -52,9 +52,9 @@ namespace DeviceAPI {
                                {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_CC.c_str(),                    DeviceAPI::Tizen::PrimitiveType_String},
                                {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_BCC.c_str(),                   DeviceAPI::Tizen::PrimitiveType_String},
                                {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_BODY.c_str(),                  DeviceAPI::Tizen::PrimitiveType_String},
-                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_IS_READ.c_str(),               DeviceAPI::Tizen::PrimitiveType_Number},
-                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_HAS_ATTACHMENT.c_str(),        DeviceAPI::Tizen::PrimitiveType_Number},
-                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_PRIORITY.c_str(),  DeviceAPI::Tizen::PrimitiveType_Number},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_IS_READ.c_str(),               DeviceAPI::Tizen::PrimitiveType_Boolean},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_HAS_ATTACHMENT.c_str(),        DeviceAPI::Tizen::PrimitiveType_Boolean},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_PRIORITY.c_str(),  DeviceAPI::Tizen::PrimitiveType_Boolean},
                                {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_SUBJECT.c_str(),               DeviceAPI::Tizen::PrimitiveType_String},
                                {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_IS_RESPONSE_TO.c_str(),        DeviceAPI::Tizen::PrimitiveType_String},
                                {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_MESSAGE_STATUS.c_str(),        DeviceAPI::Tizen::PrimitiveType_String},
index 04d1705..18fba7a 100755 (executable)
@@ -800,23 +800,23 @@ namespace DeviceAPI {
 //                             endTime = convertToTimeFormat(endValueStr);
 
                                if (!initialValue->isNullOrUndefined()) {
-                                       if( DeviceAPI::Tizen::PrimitiveType_Time==initialValue->getType() ) {
-                                               LogDebug("<<<initialValue->getType()[" << initialValue->getType() <<"]");                                       
-                                               startTime = initialValue->getDateTm();
+                                       if( initialValue->isType(DeviceAPI::Tizen::PrimitiveType_Time) ) {
+                                               LogDebug("<<<initialValue->getType()[PrimitiveType_Time]");
+                                               startTime = *initialValue->getDateTm();
                                        }
                                        else {
-                                               LogError("initialValue->getType() : [" << initialValue->getType() << "]");                                      
+                                               LogError("initialValue->getType()");
                                                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid initialValue Type");
                                        }
                                }
                                
                                if (!endValue->isNullOrUndefined()) {
-                                       if( DeviceAPI::Tizen::PrimitiveType_Time==endValue->getType() ) {
-                                               LogDebug("<<<initialValue->getType()[" << endValue->getType() <<"]");                                   
-                                               endTime = endValue->getDateTm();
+                                       if( endValue->isType(DeviceAPI::Tizen::PrimitiveType_Time) ) {
+                                               LogDebug("<<<initialValue->getType()[PrimitiveType_Time]");
+                                               endTime = *endValue->getDateTm();
                                                LogDebug("<<<valueStr[" << endValueStr <<"]");                                  
                                        } else {
-                                               LogError("endValue->getType() : [" << endValue->getType() << "]");                                      
+                                               LogError("endValue->getType()");
                                                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid endValue Type");
                                        }
                                }
index eca0fd5..b52e4bb 100644 (file)
@@ -19,7 +19,6 @@
 #include "MsgSqliteWrapper.h"
 
 #include <dpl/log/log.h>
-#include <glib.h>
 
 #define MAX_THREAD_ADDR_LEN    40
 #define MAX_THREAD_NAME_LEN    195
@@ -40,10 +39,6 @@ namespace{
                char                                                                            displayName[MAX_DISPLAY_NAME_LEN+1];    /**< The display name of an address */
        } MSG_ADDRESS_INFO_S;
 
-       typedef struct _msg_struct{
-               int type;
-               void *data;
-       }msg_struct_s;
 
        typedef struct
        {
@@ -73,8 +68,8 @@ namespace{
                size_t                                  dataSize;                                                                                                                       /**< Indicates the data size. The unit is byte. */
                void                                    *pData;                                                                                                                         /**< Indicates the message payload information as a body. default character encoding is UTF-8*/
                void                                    *pMmsData;                                                                                                              /**< Indicates the message payload information as a body. default character encoding is UTF-8*/
-//             size_t                          mmsDataSize;
-       } MSG_MESSAGE_HIDDEN_S;
+               size_t                                  mmsDataSize;            
+       } MSG_MESSAGE_HIDDEN_S_M;
 
 
        /**
@@ -93,7 +88,7 @@ namespace{
                int                                     smsCnt;                                                                                                                 /**< Indicates the SMS messages from the Peer. */
                int                                     mmsCnt;                                                                                                                 /**< Indicates the MMS messages from the Peer. */
                bool                                    bProtected;                                                                                                     /**< Indicates whether the thread includes protected messages.  */
-       } MSG_THREAD_VIEW_S;
+       } MSG_THREAD_VIEW_S_M;
 
        enum _MSG_MAIN_TYPE_E
        {
@@ -256,7 +251,7 @@ FROM " << MSGFW_MESSAGE_TABLE_NAME << " A, " << MSGFW_ADDRESS_TABLE_NAME << " B
 
        pMsgList->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t) * rowCnt];
 
-       MSG_MESSAGE_HIDDEN_S *pTmp = NULL;
+       MSG_MESSAGE_HIDDEN_S_M *pTmp = NULL;
        msg_struct_s *msg = NULL;
 
        for (int i = 0; i < rowCnt; i++) {
@@ -265,11 +260,11 @@ FROM " << MSGFW_MESSAGE_TABLE_NAME << " A, " << MSGFW_ADDRESS_TABLE_NAME << " B
                msg = (msg_struct_s *)pMsgList->msg_struct_info[i];
 
                msg->type = MSG_STRUCT_MESSAGE_INFO;
-               msg->data = (int *)new char[sizeof(MSG_MESSAGE_HIDDEN_S)];
+               msg->data = (int *)new char[sizeof(MSG_MESSAGE_HIDDEN_S_M)];
 
-               pTmp = (MSG_MESSAGE_HIDDEN_S *)msg->data;
+               pTmp = (MSG_MESSAGE_HIDDEN_S_M *)msg->data;
 
-               memset(pTmp, 0x00, sizeof(MSG_MESSAGE_HIDDEN_S));
+               memset(pTmp, 0x00, sizeof(MSG_MESSAGE_HIDDEN_S_M));
 
                pTmp->pData = NULL;
                pTmp->pMmsData = NULL;
@@ -446,7 +441,7 @@ FROM " << MSGFW_ADDRESS_TABLE_NAME << " A, "  << MSGFW_CONVERSATION_TABLE_NAME
 
        pThreadViewList->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t)*rowCnt];
 
-       MSG_THREAD_VIEW_S *pTmp = NULL;
+       MSG_THREAD_VIEW_S_M *pTmp = NULL;
        msg_struct_s *thread_t = NULL;
 
        for (int i = 0; i < rowCnt; i++) {
@@ -454,10 +449,10 @@ FROM " << MSGFW_ADDRESS_TABLE_NAME << " A, "  << MSGFW_CONVERSATION_TABLE_NAME
                pThreadViewList->msg_struct_info[i] = (msg_struct_t)thread_t;
 
                thread_t->type = MSG_STRUCT_THREAD_INFO;
-               thread_t->data = new MSG_THREAD_VIEW_S;
+               thread_t->data = new MSG_THREAD_VIEW_S_M;
 
-               pTmp = (MSG_THREAD_VIEW_S *)thread_t->data;
-               memset(pTmp, 0x00, sizeof(MSG_THREAD_VIEW_S));
+               pTmp = (MSG_THREAD_VIEW_S_M *)thread_t->data;
+               memset(pTmp, 0x00, sizeof(MSG_THREAD_VIEW_S_M));
 
                pTmp->threadId = dbHandle.getColumnToInt(index++);
 
@@ -483,3 +478,148 @@ FROM " << MSGFW_ADDRESS_TABLE_NAME << " A, "  << MSGFW_CONVERSATION_TABLE_NAME
        return MSG_SUCCESS;
 }
 
+//int msg_release_list_struct(msg_struct_list_s *msg_struct_list)
+int MessageStorageReader::msg_release_list_struct_private(msg_struct_list_s *msg_struct_list)
+{
+       LogDebug("enter");
+       msg_error_t err = MSG_SUCCESS;
+
+       if (msg_struct_list == NULL)
+               return MSG_ERR_NULL_POINTER;
+
+       if (msg_struct_list->msg_struct_info == NULL) {
+               if (msg_struct_list->nCount > 0)
+                       msg_struct_list->nCount = 0;
+               return err;
+       }
+
+       if(msg_struct_list->nCount > 0) {
+               int listCnt = msg_struct_list->nCount;
+
+               for(int i = 0; i < listCnt; i++) {
+                       release_msg_struct_private(&(msg_struct_list->msg_struct_info[i]));
+               }
+       }
+
+       delete [] msg_struct_list->msg_struct_info;
+       msg_struct_list->msg_struct_info = NULL;
+
+// for private only start
+//     msg_struct_list->nCount = 0;
+//     malloc_trim(0);
+//     MsgReleaseMemoryDB();
+// for private only end
+
+       LogDebug("end");
+       return err;
+}
+
+int MessageStorageReader::release_msg_struct_private(msg_struct_t *msg_struct_handle)
+{
+       LogDebug("enter");
+
+       msg_error_t err = MSG_SUCCESS;
+
+       if (msg_struct_handle == NULL || *msg_struct_handle == NULL)
+               return MSG_ERR_NULL_POINTER;
+
+       msg_struct_s *msg_struct = (msg_struct_s *)*msg_struct_handle;
+
+       switch(msg_struct->type)
+       {
+       case MSG_STRUCT_MESSAGE_INFO :
+       {
+               msg_message_release_private(&msg_struct);
+
+               *msg_struct_handle = NULL;
+               break;
+       }
+       case MSG_STRUCT_THREAD_INFO:
+       {
+               delete (MSG_THREAD_VIEW_S_M*)(msg_struct->data);
+               msg_struct->data = NULL;
+
+               delete msg_struct;
+               *msg_struct_handle = NULL;
+               break;
+       }
+       default :
+               err = MSG_ERR_INVALID_PARAMETER;
+               break;
+       }
+       LogDebug("end");
+
+       return err;
+}
+
+int MessageStorageReader::msg_message_release_private(msg_struct_s **msg_struct)
+{
+       LogDebug("enter");
+
+       MSG_MESSAGE_HIDDEN_S_M *msg = (MSG_MESSAGE_HIDDEN_S_M *)(*msg_struct)->data;
+
+       if (msg->pData) {
+               delete [] static_cast<char*>(msg->pData);
+               msg->pData = NULL;
+       }
+
+       if (msg->pMmsData) {
+               delete [] static_cast<char*>(msg->pMmsData);
+               msg->pMmsData = NULL;
+               msg->mmsDataSize = 0;
+       }
+
+       // Memory Free
+       if (msg->addr_list!= NULL)
+       {
+               for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
+                       msg_struct_s * addrInfo = (msg_struct_s *)msg->addr_list->msg_struct_info[i];
+                       delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
+                       addrInfo->data = NULL;
+                       delete (msg_struct_s *)msg->addr_list->msg_struct_info[i];
+                       msg->addr_list->msg_struct_info[i] = NULL;
+               }
+
+               delete [] msg->addr_list->msg_struct_info;
+
+               delete msg->addr_list;
+               msg->addr_list = NULL;
+       }
+
+// for private only start
+       // Free GList *addressList
+//     if (msg->addressList) {
+//             g_list_free_full(msg->addressList, __msg_message_release_address_struct_private);
+//             msg->addressList = NULL;
+//     }
+// for private only end
+
+       delete msg;
+       (*msg_struct)->data = NULL;
+
+       delete (msg_struct_s *)*msg_struct;
+       *msg_struct = NULL;
+
+       LogDebug("end");
+
+       return MSG_SUCCESS;
+}
+
+void MessageStorageReader::__msg_message_release_address_struct_private(gpointer data) 
+{
+       LogDebug("enter");
+       if (data == NULL)
+               return;
+
+       msg_struct_s *addr_struct = (msg_struct_s *)data;
+       MSG_ADDRESS_INFO_S *addrInfo = (MSG_ADDRESS_INFO_S *)addr_struct->data;
+
+       delete (MSG_ADDRESS_INFO_S *)addrInfo;
+
+       addr_struct->data = NULL;
+
+       delete addr_struct;
+       LogDebug("end");
+}
+
+
index fe47af9..c3c3b26 100644 (file)
 #include "msg_types.h"
 #include "MsgSqliteWrapper.h"
 #include "msg_storage_types.h"
+#include "MessageStorageReaderData.h"
 
 #include <string>
+#include <glib.h>
 
 class MessageStorageReader {
        private:
@@ -37,7 +39,13 @@ class MessageStorageReader {
 
        public:
                int queryMessage(const std::string& whereClause, const std::string& orderLimit, /*out*/msg_struct_list_s *pMsgFolderViewList);
-               int queryConversation(const std::string& whereClause, const std::string& orderLimit, /*out*/msg_struct_list_s *pThreadViewList  );
+               int queryConversation(const std::string& whereClause, const std::string& orderLimit, /*out*/msg_struct_list_s *pThreadViewList);
+
+               static void __msg_message_release_address_struct_private(gpointer data);
+               int msg_message_release_private(msg_struct_s **msg_struct);
+               int release_msg_struct_private(msg_struct_t *msg_struct_handle);
+               int msg_release_list_struct_private(msg_struct_list_s *msg_struct_list);
+               int msg_release_struct_private(msg_struct_list_s *msg_struct_list);
 };
 
 #endif /* MessageStorageReader_H_ */
diff --git a/src/Messaging/messageDB/MessageStorageReaderData.h b/src/Messaging/messageDB/MessageStorageReaderData.h
new file mode 100644 (file)
index 0000000..f646f19
--- /dev/null
@@ -0,0 +1,26 @@
+//\r
+// Tizen Web Device API\r
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+\r
+#ifndef MessageStorageReaderData_H_\r
+#define MessageStorageReaderData_H_\r
+\r
+typedef struct _msg_struct{\r
+       int type;\r
+       void *data;\r
+}msg_struct_s;\r
+\r
+#endif /* MessageStorageReaderData_H_ */\r
index a50fd48..487fd72 100755 (executable)
@@ -14,7 +14,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${application_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${filesystem_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
index 1f2a103..e7e94a2 100644 (file)
@@ -18,7 +18,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
 )
 
old mode 100755 (executable)
new mode 100644 (file)
index 079ee79..cda183e
@@ -147,6 +147,8 @@ JSValueRef JSPackageManager::install(JSContextRef context,
                        oncompleteCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
                        oncompleteCb->setSuccessCallback(oncomplete);
                } else {
+                       if (onprogressCb)
+                               delete onprogressCb;
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "oncomplete is not function");
                }
 
@@ -216,6 +218,8 @@ JSValueRef JSPackageManager::uninstall(JSContextRef context,
                        oncompleteCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
                        oncompleteCb->setSuccessCallback(oncomplete);
                } else {
+                       if (onprogressCb)
+                               delete onprogressCb;
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "oncomplete is not function");
                }
 
@@ -346,6 +350,9 @@ JSValueRef JSPackageManager::setPackageInfoEventListener(JSContextRef context,
                        onupdatedCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
                        onupdatedCb->setSuccessCallback(onupdated);
                } else {
+                       if (oninstalledCb)
+                               delete oninstalledCb;
+
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "onupdated is not function");
                }
 
@@ -355,6 +362,11 @@ JSValueRef JSPackageManager::setPackageInfoEventListener(JSContextRef context,
                        onuninstalledCb = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context));
                        onuninstalledCb->setSuccessCallback(onuninstalled);
                } else {
+                       if (oninstalledCb)
+                               delete oninstalledCb;
+                       if (onupdatedCb)
+                               delete onupdatedCb;
+       
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "onuninstalled is not function");
                }
 
old mode 100755 (executable)
new mode 100644 (file)
index 6a660d6..5cb5fca
@@ -97,6 +97,14 @@ PackageInfoEventCallback::PackageInfoEventCallback(CallbackUserData* oninstalled
 
 PackageInfoEventCallback::~PackageInfoEventCallback()
 {
+       if (m_oninstalled)
+               delete m_oninstalled;
+
+       if (m_onupdated)
+               delete m_onupdated;
+
+       if (m_onuninstalled)
+               delete m_onuninstalled;
 }
 
 CallbackUserData* PackageInfoEventCallback::getOnInstalled()
@@ -132,6 +140,15 @@ PackageInstallEventCallback::~PackageInstallEventCallback()
                //package_manager_request_destroy(m_request_handle);
                package_manager_client_destroy(m_request_handle);
        }
+       
+       if (m_onprogress)
+               delete m_onprogress;
+
+       if (m_oncomplete)
+               delete m_oncomplete;
+
+       if (m_onerror)
+               delete m_onerror;
 }
 
 CallbackUserData* PackageInstallEventCallback::getOnProgress()
@@ -477,6 +494,10 @@ void install_request_cb(int id, const char *type, const char *package,
                // this api is not supported from platform.
                //package_manager_request_destroy(callback->getHandle());
                package_manager_client_destroy(callback->getHandle());
+
+               //clean-up callback object
+               delete callback;
+               
                break;
        }
        case PACAKGE_MANAGER_EVENT_STATE_FAILED: {
@@ -495,6 +516,10 @@ void install_request_cb(int id, const char *type, const char *package,
                // this api is not supported from platform.
                //package_manager_request_destroy(callback->getHandle());
                package_manager_client_destroy(callback->getHandle());
+
+               //clean-up callback object
+               delete callback;
+               
                break;
        }
        case PACAKGE_MANAGER_EVENT_STATE_STARTED:
@@ -515,10 +540,13 @@ void install_request_cb(int id, const char *type, const char *package,
                // this api is not supported from platform.
                //package_manager_request_destroy(callback->getHandle());
                package_manager_client_destroy(callback->getHandle());
+
+               //clean-up callback object
+               delete callback;
+               
                break;
        }
 
-
 }
 
 void PackageManager::install(string pkgPath, PackageInstallEventCallback* callback)
@@ -580,6 +608,8 @@ void PackageManager::uninstall(string pkgPath, PackageInstallEventCallback* call
                                JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::UNKNOWN_ERROR, "Platform Error");
                        errCallback->callSuccessCallback(error);
                }
+               //clean-up callback object
+               delete callback;
                return;
        }
 
@@ -592,6 +622,8 @@ void PackageManager::uninstall(string pkgPath, PackageInstallEventCallback* call
                        // TODO: how can I handle about uninstallable package???
                        errCallback->callSuccessCallback(error);
                }
+               //clean-up callback object
+               delete callback;
                return;
        }
 
@@ -604,6 +636,8 @@ void PackageManager::uninstall(string pkgPath, PackageInstallEventCallback* call
                                JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::UNKNOWN_ERROR, "Platform Error");
                        errCallback->callSuccessCallback(error);
                }
+               //clean-up callback object
+               delete callback;
                return;
        }
 }
index 839d82b..427d1cd 100755 (executable)
@@ -12,7 +12,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
 )
 
index 8c9e853..45547e7 100755 (executable)
@@ -113,10 +113,11 @@ void PowerManager::request(PowerResource resource, PowerState state){
             break;
         case PowerState::SCREENBRIGHT :
         {
-            int maxBrightness = 100;
+            int maxBrightness;
             ret = device_get_max_brightness(0, &maxBrightness);
             if( DEVICE_ERROR_NONE!=ret) {
                 LOGE("Platform error while getting max brightness: %d", ret);
+                throw UnknownException("Platform error while getting max brightness");
             }
 
             ret = device_set_brightness(0, maxBrightness);
@@ -179,10 +180,17 @@ void PowerManager::setScreenBrightness(double brightness){
     int ret;
     if( brightness > 1 || brightness < 0 )
         throw InvalidValuesException("brightness should be 0 <= brightness <= 1");
-    ret = device_set_brightness(0, (int)(brightness*100));
+    int maxBrightness;
+    ret = device_get_max_brightness(0, &maxBrightness);
+    if( ret != 0 ){
+        LOGE("Platform error while setting restore brightness: %d", ret);
+        throw UnknownException("Platform error while getting max brightness");
+    }
+
+    ret = device_set_brightness(0, (int)(brightness*maxBrightness));
     if( DEVICE_ERROR_NONE!=ret )
         throw UnknownException("Platform error while setting brightness.");
-    LOGI("Set the brightness value: %d", (int)(brightness*100));
+    LOGI("Set the brightness value: %d", (int)(brightness*maxBrightness));
 }
 
 bool PowerManager::isScreenOn(){
old mode 100755 (executable)
new mode 100644 (file)
index 396f018..0684729
@@ -1,10 +1,13 @@
+
 SET(TARGET_NAME ${push_target})
 SET(DESTINATION_NAME ${push_dest})
+SET(TARGET_IMPL_NAME ${push_impl})
 
 PKG_CHECK_MODULES(platform_pkgs_push REQUIRED push capi-appfw-application)
 
 INCLUDE_DIRECTORIES(
        ${TOP}/Common
+       ${TOP}/Common/TimeTracer
        ${TOP}/Application
        ${platform_pkgs_push_INCLUDE_DIRS}
 )
@@ -12,37 +15,41 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${application_dest}
+       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
+)
+
+SET(SRCS_IMPL
+    JSPushManager.cpp
+    JSPushMessage.cpp
+    PushManager.cpp
+    PushMessage.cpp
+)
+
+ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL})
+
+TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME}
+       ${LIBS_COMMON}
+    ${tizen_impl}
+    ${application_impl}
+    "-Wl,--no-as-needed" ${application_config}
+       ${platform_pkgs_push_LIBRARIES}
 )
 
 SET(SRCS
-       IPushManager.cpp
-       PushMessage.cpp
-       PushManager.cpp
-       PushResponseDispatcher.cpp
-       PushConverter.cpp
-       JSPushManager.cpp
-       JSPushMessage.cpp
-       PushListenerManager.cpp
-       PushAsyncCallbackManager.cpp
-       plugin_initializer.cpp
        plugin_config.cpp
+       plugin_initializer.cpp
 )
 
 ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS})
 
 TARGET_LINK_LIBRARIES(${TARGET_NAME}
-       ${LIBS_COMMON}
-       ${tizen_impl}
-       ${application_impl}
-       "-Wl,--no-as-needed" ${application_config}
-       ${platform_pkgs_push_LIBRARIES}
+       ${TARGET_IMPL_NAME}
 )
 
-INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME})
+INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME})
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME})
 INSTALL(
-       DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/push
-       FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE
+        DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/push
+        FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE
 )
diff --git a/src/Push/IEventConnectService.h b/src/Push/IEventConnectService.h
deleted file mode 100755 (executable)
index 6633715..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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 _ABSTRACT_LAYER_IEVENT_CONNECT_SERVICE_H_
-#define _ABSTRACT_LAYER_IEVENT_CONNECT_SERVICE_H_
-
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-
-#include "OnPushNotified.h"
-
-namespace DeviceAPI {
-namespace Push {
-
-class IEventConnectService : public WrtDeviceApis::Commons::IEvent<IEventConnectService>
-{
-    bool m_result;
-    OnPushNotifiedEmitterPtr m_emitter;
-
-  public:
-    void setResult(bool value)
-    {
-        m_result = value;
-    }
-    bool getResult() const
-    {
-        return m_result;
-    }
-
-    void setEmitter(OnPushNotifiedEmitterPtr value)
-    {
-        m_emitter = value;
-    }
-    OnPushNotifiedEmitterPtr getEmitter() const
-    {
-        return m_emitter;
-    }
-
-    IEventConnectService() : m_result(false),
-        m_emitter(NULL)
-    {
-    }
-    ~IEventConnectService()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventConnectService> IEventConnectServicePtr;
-
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_CONNECT_SERVICE_H_ */
-
diff --git a/src/Push/IEventDisconnectService.h b/src/Push/IEventDisconnectService.h
deleted file mode 100755 (executable)
index 70db76f..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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 _ABSTRACT_LAYER_IEVENT_DISCONNECT_SERVICE_H_
-#define _ABSTRACT_LAYER_IEVENT_DISCONNECT_SERVICE_H_
-
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-
-namespace DeviceAPI {
-namespace Push {
-
-class IEventDisconnectService : public WrtDeviceApis::Commons::IEvent<IEventDisconnectService>
-{
-    bool m_result;
-
-  public:
-    void setResult(bool value)
-    {
-        m_result = value;
-    }
-    bool getResult() const
-    {
-        return m_result;
-    }
-
-    IEventDisconnectService() : m_result(false)
-    {
-    }
-    ~IEventDisconnectService()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventDisconnectService> IEventDisconnectServicePtr;
-
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_DISCONNECT_SERVICE_H_ */
\ No newline at end of file
diff --git a/src/Push/IEventGetRegistrationId.h b/src/Push/IEventGetRegistrationId.h
deleted file mode 100755 (executable)
index 8ab1e8a..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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 _ABSTRACT_LAYER_IEVENT_GET_REGISTRATION_ID_H_
-#define _ABSTRACT_LAYER_IEVENT_GET_REGISTRATION_ID_H_
-
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-
-namespace DeviceAPI {
-namespace Push {
-
-class IEventGetRegistrationId : public WrtDeviceApis::Commons::IEvent<IEventGetRegistrationId>
-{
-    bool m_result;
-    std::string m_registrationId;
-
-  public:
-    void setResult(bool value)
-    {
-        m_result = value;
-    }
-    bool getResult() const
-    {
-        return m_result;
-    }
-
-    void setRegistrationId(std::string value)
-    {
-        m_registrationId = value;
-    }
-    std::string getRegistrationId() const
-    {
-        return m_registrationId;
-    }
-
-    IEventGetRegistrationId() : m_result(false),
-        m_registrationId("")
-    {
-    }
-    ~IEventGetRegistrationId()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventGetRegistrationId> IEventGetRegistrationIdPtr;
-
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_GET_REGISTRATION_ID_H_ */
\ No newline at end of file
diff --git a/src/Push/IEventRegisterService.h b/src/Push/IEventRegisterService.h
deleted file mode 100644 (file)
index c59cdf0..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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 _ABSTRACT_LAYER_IEVENT_REGISTER_SERVICE_H_
-#define _ABSTRACT_LAYER_IEVENT_REGISTER_SERVICE_H_
-
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-#include <ApplicationControl.h>
-
-namespace DeviceAPI {
-namespace Push {
-
-class IEventRegisterService : public WrtDeviceApis::Commons::IEvent<IEventRegisterService>
-{
-    bool m_result;
-    DeviceAPI::Application::ApplicationControlPtr m_appService;
-    std::string m_registrationId;
-
-  public:
-    void setResult(bool value)
-    {
-        m_result = value;
-    }
-    bool getResult() const
-    {
-        return m_result;
-    }
-
-    void setApplicationControl(DeviceAPI::Application::ApplicationControlPtr value)
-    {
-        m_appService = value;
-    }
-    DeviceAPI::Application::ApplicationControlPtr getApplicationControl() const
-    {
-        return m_appService;
-    }
-
-    void setRegistrationId(std::string value)
-    {
-        m_registrationId = value;
-    }
-    std::string getRegistrationId() const
-    {
-        return m_registrationId;
-    }
-
-    IEventRegisterService() : m_result(false),
-        m_appService(NULL),
-        m_registrationId("")
-    {
-    }
-    ~IEventRegisterService()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventRegisterService> IEventRegisterServicePtr;
-
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_REGISTER_SERVICE_H_ */
diff --git a/src/Push/IEventUnregisterService.h b/src/Push/IEventUnregisterService.h
deleted file mode 100755 (executable)
index e61c4f1..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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 _ABSTRACT_LAYER_IEVENT_UNREGISTER_SERVICE_H_
-#define _ABSTRACT_LAYER_IEVENT_UNREGISTER_SERVICE_H_
-
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-
-namespace DeviceAPI {
-namespace Push {
-
-class IEventUnregisterService : public WrtDeviceApis::Commons::IEvent<IEventUnregisterService>
-{
-    bool m_result;
-
-  public:
-    void setResult(bool value)
-    {
-        m_result = value;
-    }
-    bool getResult() const
-    {
-        return m_result;
-    }
-
-    IEventUnregisterService() : m_result(false)
-    {
-    }
-    ~IEventUnregisterService()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventUnregisterService> IEventUnregisterServicePtr;
-
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_UNREGISTER_SERVICE_H_ */
diff --git a/src/Push/IPushManager.cpp b/src/Push/IPushManager.cpp
deleted file mode 100755 (executable)
index 157384b..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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 "IPushManager.h"
-#include <Commons/ThreadPool.h>
-
-namespace DeviceAPI {
-namespace Push {
-
-IPushManager::IPushManager() :
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventRegisterService >(WrtDeviceApis::Commons::ThreadEnum::PUSH_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventUnregisterService >(WrtDeviceApis::Commons::ThreadEnum::PUSH_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventConnectService >(WrtDeviceApis::Commons::ThreadEnum::PUSH_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventDisconnectService >(WrtDeviceApis::Commons::ThreadEnum::PUSH_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetRegistrationId >(WrtDeviceApis::Commons::ThreadEnum::PUSH_THREAD)
-{
-}
-
-IPushManager::~IPushManager()
-{
-}
-
-void IPushManager::registerService(const IEventRegisterServicePtr &event)
-{
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventRegisterService>::PostRequest(event);
-}
-
-void IPushManager::unregisterService(const IEventUnregisterServicePtr &event)
-{
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventUnregisterService>::PostRequest(event);
-}
-
-void IPushManager::connectService(const IEventConnectServicePtr &event)
-{
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventConnectService>::PostRequest(event);
-}
-
-void IPushManager::disconnectService(const IEventDisconnectServicePtr &event)
-{
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventDisconnectService>::PostRequest(event);
-}
-
-void IPushManager::getRegistrationId(const IEventGetRegistrationIdPtr &event)
-{
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetRegistrationId>::PostRequest(event);
-}
-
-}
-}
diff --git a/src/Push/IPushManager.h b/src/Push/IPushManager.h
deleted file mode 100755 (executable)
index d03ef07..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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 _ABSTRACT_LAYER_IPUSH_MANAGER_H_
-#define _ABSTRACT_LAYER_IPUSH_MANAGER_H_
-
-#include "IEventRegisterService.h"
-#include "IEventUnregisterService.h"
-#include "IEventConnectService.h"
-#include "IEventDisconnectService.h"
-#include "IEventGetRegistrationId.h"
-
-#include <dpl/shared_ptr.h>
-
-namespace DeviceAPI {
-namespace Push {
-
-class IPushManager : public WrtDeviceApis::Commons::EventRequestReceiver< IEventRegisterService >,
-    public WrtDeviceApis::Commons::EventRequestReceiver< IEventUnregisterService >,
-    public WrtDeviceApis::Commons::EventRequestReceiver< IEventConnectService >,
-    public WrtDeviceApis::Commons::EventRequestReceiver< IEventDisconnectService >,
-    public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetRegistrationId >
-{
-  public:
-    IPushManager();
-    virtual ~IPushManager();
-    virtual void registerService(const IEventRegisterServicePtr &event);
-    virtual void unregisterService(const IEventUnregisterServicePtr &event);
-    virtual void connectService(const IEventConnectServicePtr &event);
-    virtual void disconnectService(const IEventDisconnectServicePtr &event);
-    virtual void getRegistrationId(const IEventGetRegistrationIdPtr &event);
-
-  protected:
-    virtual void OnRequestReceived(const IEventRegisterServicePtr &event) = 0;
-    virtual void OnRequestReceived(const IEventUnregisterServicePtr &event) = 0;
-    virtual void OnRequestReceived(const IEventConnectServicePtr &event) = 0;
-    virtual void OnRequestReceived(const IEventDisconnectServicePtr &event) = 0;
-    virtual void OnRequestReceived(const IEventGetRegistrationIdPtr &event) = 0;
-};
-
-typedef DPL::SharedPtr<IPushManager> IPushManagerPtr;
-
-}
-}
-
-#endif /* _ABSTRACT_LAYER_IPUSH_MANAGER_H_ */
index ee25911..5e7b706 100644 (file)
@@ -1,50 +1,36 @@
-/*
- * 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 <dpl/log/log.h>
-#include "OnPushNotified.h"
-#include "PushManager.h"
-
-#include <CommonsJavaScript/PrivateObject.h>
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <CommonsJavaScript/Utils.h>
-#include <CommonsJavaScript/Validator.h>
-#include <CommonsJavaScript/ScopedJSStringRef.h>
-#include <JSTizenException.h>
-#include <JSTizenExceptionFactory.h>
-#include <SecurityExceptions.h>
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 "JSPushManager.h"
-#include "PushConverter.h"
-#include "JSPushMessage.h"
-#include "plugin_config.h"
-#include "PushResponseDispatcher.h"
+#include <SecurityExceptions.h>
 
-#include "PushListenerManager.h"
-#include "PushAsyncCallbackManager.h"
+#include <JSUtil.h>
+#include <JSWebAPIError.h>
+#include <ArgumentValidator.h>
+#include <GlobalContextManager.h>
+#include <MultiCallbackUserData.h>
+#include <PlatformException.h>
 
 #include <JSApplicationControl.h>
-#include <ApplicationControl.h>
-#include <ApplicationConverter.h>
+
+#include "plugin_config.h"
+
+#include "JSPushManager.h"
 
 using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace DeviceAPI::Common;
 
 namespace DeviceAPI {
@@ -53,12 +39,12 @@ namespace Push {
 JSClassDefinition JSPushManager::m_classInfo = {
     0,
     kJSClassAttributeNone,
-    TIZEN_PUSH_MANAGER_INTERFACE,
+    "PushManager",
     NULL, //ParentClass
     NULL, //StaticValues
-    m_function,
-    initialize,
-    finalize,
+    m_function, //StaticFunctions
+    initialize, //Initialize
+    finalize, //Finalize
     NULL, //HasProperty,
     NULL, //GetProperty,
     NULL, //SetProperty,
@@ -71,52 +57,39 @@ JSClassDefinition JSPushManager::m_classInfo = {
 };
 
 JSStaticFunction JSPushManager::m_function[] = {
-    { PUSH_FUNCTION_API_REGISTER_SERVICE, registerService, kJSPropertyAttributeNone },
-    { PUSH_FUNCTION_API_UNREGISTER_SERVICE, unregisterService, kJSPropertyAttributeNone },
-    { PUSH_FUNCTION_API_CONNECT_SERVICE, connectService, kJSPropertyAttributeNone },
-    { PUSH_FUNCTION_API_DISCONNECT_SERVICE, disconnectService, kJSPropertyAttributeNone },
-    { PUSH_FUNCTION_API_GET_REGISTRATION_ID, getRegistrationId, kJSPropertyAttributeNone },
-
+    { PUSH_MANAGER_API_REGISTER_SERVICE, registerService, kJSPropertyAttributeNone },
+    { PUSH_MANAGER_API_UNREGISTER_SERVICE, unregisterService, kJSPropertyAttributeNone },
+    { PUSH_MANAGER_API_CONNECT_SERVICE, connectService, kJSPropertyAttributeNone },
+    { PUSH_MANAGER_API_DISCONNECT_SERVICE, disconnectService, kJSPropertyAttributeNone },
+    { PUSH_MANAGER_API_GET_REGISTRATION_ID, getRegistrationId, kJSPropertyAttributeNone },
     { 0, 0, 0 }
 };
 
 JSClassRef JSPushManager::m_jsClassRef = JSClassCreate(JSPushManager::getClassInfo());
 
-void JSPushManager::initialize(JSContextRef context, JSObjectRef object)
+const JSClassRef JSPushManager::getClassRef()
 {
-    if (!JSObjectGetPrivate(object)) {
-        LogInfo("Create push manager private object.");
-        IPushManagerPtr push(new PushManager());
-        PushManagerPrivObject *priv = new PushManagerPrivObject(context, push);
-        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
-            delete priv;
-        }
-    } else {
-        LogInfo("Private object already set.");
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_classInfo);
     }
+    return m_jsClassRef;
 }
 
-void JSPushManager::finalize(JSObjectRef object)
+const JSClassDefinition* JSPushManager::getClassInfo()
 {
-    PushManagerPrivObject *priv = static_cast<PushManagerPrivObject*>(JSObjectGetPrivate(object));
-    if (priv) {
-        LogInfo("Deleting push manager private object.");
-        delete priv;
-        JSObjectSetPrivate(object, NULL);
-    }
+    return &m_classInfo;
 }
 
-const JSClassRef JSPushManager::getClassRef()
+void JSPushManager::initialize(JSContextRef context, JSObjectRef object)
 {
-    if (!m_jsClassRef) {
-        m_jsClassRef = JSClassCreate(&m_classInfo);
+    if (!JSObjectGetPrivate(object)) {
+        PushManager *priv = PushManager::getInstance();
+        JSObjectSetPrivate(object, static_cast<void*>(priv));
     }
-    return m_jsClassRef;
 }
 
-const JSClassDefinition* JSPushManager::getClassInfo()
+void JSPushManager::finalize(JSObjectRef object)
 {
-    return &m_classInfo;
 }
 
 JSValueRef JSPushManager::registerService(JSContextRef context,
@@ -126,89 +99,55 @@ JSValueRef JSPushManager::registerService(JSContextRef context,
         const JSValueRef arguments[],
         JSValueRef* exception)
 {
-    LogDebug("entered");
-
-    PushManagerPrivObject *privateObject =
-        static_cast<PushManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-
-    AceSecurityStatus status = PUSH_CHECK_ACCESS(PUSH_FUNCTION_API_REGISTER_SERVICE);
-
+    AceSecurityStatus status = PUSH_CHECK_ACCESS(PUSH_MANAGER_API_REGISTER_SERVICE);
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    Try
-    {
-        if (!privateObject) {
-            ThrowMsg(ConversionException, "Object is null.");
+    try {
+        // Private Object
+        PushManager *priv = static_cast<PushManager *>(JSObjectGetPrivate(thisObject));
+        if (!priv) {
+            throw TypeMismatchException("Private object is NULL.");
         }
 
-        IPushManagerPtr pushManager = privateObject->getObject();
-
-        JSContextRef globalContext = privateObject->getContext();
+        ArgumentValidator validator(context, argumentCount, arguments);
 
-        PushConverter converter(context);
-
-        if (argumentCount<2) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
+        // appControl
+        DeviceAPI::Application::ApplicationControlPtr appControl(NULL);
+        JSObjectRef appControlObj = validator.toObject(0, DeviceAPI::Application::JSApplicationControl::getClassRef());
+        if (appControlObj) {
+            JSApplicationControlPriv *priv = static_cast<JSApplicationControlPriv *>(JSObjectGetPrivate(appControlObj));
+            if (!priv) {
+                throw TypeMismatchException("ApplicationControl's private object is NULL.");
+            }
+            appControl = priv->getObject();
         }
 
-        DeviceAPI::Application::ApplicationControlPtr appService(NULL);
-        if(JSValueIsObjectOfClass(context, arguments[0], DeviceAPI::Application::JSApplicationControl::getClassRef())) {
-            DeviceAPI::Application::ApplicationConverter applicationConverter(context);
-            appService = applicationConverter.toApplicationControl(arguments[0]);
-            LogInfo("operation: "<<appService->getOperation()<<", mime: "<<appService->getMime()<<", uri: "<<appService->getUri());
-        } else {
-            ThrowMsg(ConversionException, "Wrong first parameter type.");
-        }
+        MultiCallbackUserDataPtr callback(new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));
 
-        JSValueRef onSuccess = NULL;
-        if (argumentCount>=2) {
-            onSuccess = converter.toFunction(arguments[1]);
-        }
-        JSValueRef onError = NULL;
-        if (argumentCount>=3) {
-            onError = converter.toFunctionOrNull(arguments[2]);
+        // successCallback
+        JSObjectRef successCallbackObj = validator.toFunction(1);
+        if (successCallbackObj) {
+            callback->setCallback("onsuccess", successCallbackObj);
         }
-        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, onSuccess, onError);
-
-               cbm->setObject(thisObject);
 
-        LogDebug("Proceed the registration request event to the platform.");
-
-        IEventRegisterServicePtr dplEvent(new IEventRegisterService());
-        dplEvent->setApplicationControl(appService);
-        dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
-        dplEvent->setForAsynchronousCall(&PushResponseDispatcher::getInstance());
+        // errorCallback
+        JSObjectRef errorCallbackObj = validator.toFunction(2, true);
+        if (errorCallbackObj) {
+            callback->setCallback("onerror", errorCallbackObj);
+        }
 
-        pushManager->registerService(dplEvent);
-               PushAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext);
-    }
-    Catch(UnsupportedException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(InvalidArgumentException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(ConversionException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch (NotFoundException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
+        // perform
+        priv->registerService(appControl, callback);
+
+        return JSValueMakeUndefined(context);
+    } catch (const BasePlatformException &err) {
+        LogError(err.getName() << ": " << err.getMessage());
+        return JSWebAPIError::throwException(context, exception, err);
+    } catch (...) {
+        DeviceAPI::Common::UnknownException err("Unknown Error in PushManager.registerService().");
+        LogError(err.getName() << ": " << err.getMessage());
+        return JSWebAPIError::throwException(context, exception, err);
     }
-    Catch(Exception)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
-    }
-
-    return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSPushManager::unregisterService(JSContextRef context,
@@ -218,75 +157,44 @@ JSValueRef JSPushManager::unregisterService(JSContextRef context,
         const JSValueRef arguments[],
         JSValueRef* exception)
 {
-    LogDebug("entered");
-
-    PushManagerPrivObject *privateObject =
-        static_cast<PushManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-
-    AceSecurityStatus status = PUSH_CHECK_ACCESS(PUSH_FUNCTION_API_UNREGISTER_SERVICE);
-
+    AceSecurityStatus status = PUSH_CHECK_ACCESS(PUSH_MANAGER_API_UNREGISTER_SERVICE);
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    Try
-    {
-        if (!privateObject) {
-            ThrowMsg(ConversionException, "Object is null.");
+    try {
+        // Private Object
+        PushManager *priv = static_cast<PushManager *>(JSObjectGetPrivate(thisObject));
+        if (!priv) {
+            throw TypeMismatchException("Private object is NULL.");
         }
 
-        IPushManagerPtr pushManager = privateObject->getObject();
-
-        JSContextRef globalContext = privateObject->getContext();
+        ArgumentValidator validator(context, argumentCount, arguments);
 
-        PushConverter converter(context);
+        MultiCallbackUserDataPtr callback(new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));
 
-        JSValueRef onSuccess = NULL;
-        if (argumentCount>=1) {
-            onSuccess = converter.toFunctionOrNull(arguments[0]);
+        // successCallback
+        JSObjectRef successCallbackObj = validator.toFunction(0, true);
+        if (successCallbackObj) {
+            callback->setCallback("onsuccess", successCallbackObj);
         }
-        JSValueRef onError = NULL;
-        if (argumentCount>=2) {
-            onError = converter.toFunctionOrNull(arguments[1]);
-        }
-        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, onSuccess, onError);
-
-               cbm->setObject(thisObject);
 
-        LogDebug("Proceed the unregistration request event to the platform.");
-
-        IEventUnregisterServicePtr dplEvent(new IEventUnregisterService());
-        dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
-        dplEvent->setForAsynchronousCall(&PushResponseDispatcher::getInstance());
+        // errorCallback
+        JSObjectRef errorCallbackObj = validator.toFunction(1, true);
+        if (errorCallbackObj) {
+            callback->setCallback("onerror", errorCallbackObj);
+        }
 
-        pushManager->unregisterService(dplEvent);
-               PushAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext);
-    }
-    Catch(UnsupportedException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(InvalidArgumentException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(ConversionException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+        // perform
+        priv->unregisterService(callback);
+
+        return JSValueMakeUndefined(context);
+    } catch (const BasePlatformException &err) {
+        LogError(err.getName() << ": " << err.getMessage());
+        return JSWebAPIError::throwException(context, exception, err);
+    } catch (...) {
+        DeviceAPI::Common::UnknownException err("Unknown Error in PushManager.unregisterService().");
+        LogError(err.getName() << ": " << err.getMessage());
+        return JSWebAPIError::throwException(context, exception, err);
     }
-    Catch (NotFoundException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(Exception)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
-    }
-
-    return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSPushManager::connectService(JSContextRef context,
@@ -296,96 +204,38 @@ JSValueRef JSPushManager::connectService(JSContextRef context,
         const JSValueRef arguments[],
         JSValueRef* exception)
 {
-    LogDebug("entered");
-
-    PushManagerPrivObject *privateObject =
-        static_cast<PushManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-
-    AceSecurityStatus status = PUSH_CHECK_ACCESS(PUSH_FUNCTION_API_CONNECT_SERVICE);
-
+    AceSecurityStatus status = PUSH_CHECK_ACCESS(PUSH_MANAGER_API_CONNECT_SERVICE);
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    Try
-    {
-        if (!privateObject) {
-            ThrowMsg(ConversionException, "Object is null.");
+    try {
+        // Private Object
+        PushManager *priv = static_cast<PushManager *>(JSObjectGetPrivate(thisObject));
+        if (!priv) {
+            throw TypeMismatchException("Private object is NULL.");
         }
 
-        IPushManagerPtr pushManager = privateObject->getObject();
+        ArgumentValidator validator(context, argumentCount, arguments);
 
-        JSContextRef globalContext = privateObject->getContext();
-
-        PushConverter converter(context);
-
-        if (argumentCount<1) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        }
-
-        JSValueRef onError = NULL;
-        if (argumentCount>=2) {
-            onError = converter.toFunctionOrNull(arguments[1]);
-        }
-        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
-
-               cbm->setObject(thisObject);
-
-        LogDebug("Proceed the connect request event to the platform.");
-
-        IEventConnectServicePtr dplEvent(new IEventConnectService());
-        dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
-        dplEvent->setForAsynchronousCall(&PushResponseDispatcher::getInstance());
-
-        // Process the listener
-        if (argumentCount>=1) {
-            JSValueRef onNotified = NULL;
-            onNotified = converter.toFunction(arguments[0]);
-            if(onNotified) {
-                LogInfo("Setting an emitter.");
-                JSCallbackManagerPtr listener = JSCallbackManager::createObject(globalContext, onNotified, NULL);
-
-                OnPushNotifiedEmitterPtr emitter(new OnPushNotifiedEmitter());
-                emitter->setListener(&PushResponseDispatcher::getInstance());
-                emitter->setEventPrivateData(DPL::StaticPointerCast<IEventPrivateData>(listener));
-                dplEvent->setEmitter(emitter);
-            } else {
-                LogWarning("Wrong listener.");
-            }
+        // notificationCallback
+        MultiCallbackUserDataPtr callback;
+        JSObjectRef notificationCallbackObj = validator.toFunction(0);
+        if (notificationCallbackObj) {
+            callback.reset(new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));
+            callback->setCallback("onsuccess", notificationCallbackObj);
         }
 
-        pushManager->connectService(dplEvent);
-               PushAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext);
-
-               PushListenerCancellerPtr canceller = PushListenerCancellerPtr(new PushListenerCanceller(globalContext, thisObject, 0));
-               DeviceAPI::Common::IListenerItemPtr listenerItem = DPL::StaticPointerCast<DeviceAPI::Common::IListenerItem>(canceller);
-               PushListenerManagerSingleton::Instance().registerListener(listenerItem, globalContext);
-    }
-    Catch(UnsupportedException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(InvalidArgumentException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(ConversionException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch (NotFoundException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(Exception)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+        // perform
+        priv->connectService(callback);
+
+        return JSValueMakeUndefined(context);
+    } catch (const BasePlatformException &err) {
+        LogError(err.getName() << ": " << err.getMessage());
+        return JSWebAPIError::throwException(context, exception, err);
+    } catch (...) {
+        DeviceAPI::Common::UnknownException err("Unknown Error in PushManager.connectService().");
+        LogError(err.getName() << ": " << err.getMessage());
+        return JSWebAPIError::throwException(context, exception, err);
     }
-
-    return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSPushManager::disconnectService(JSContextRef context,
@@ -395,50 +245,28 @@ JSValueRef JSPushManager::disconnectService(JSContextRef context,
         const JSValueRef arguments[],
         JSValueRef* exception)
 {
-    LogDebug("entered");
-
-    PushManagerPrivObject *privateObject =
-        static_cast<PushManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-
-    AceSecurityStatus status = PUSH_CHECK_ACCESS(PUSH_FUNCTION_API_DISCONNECT_SERVICE);
-
+    AceSecurityStatus status = PUSH_CHECK_ACCESS(PUSH_MANAGER_API_DISCONNECT_SERVICE);
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    Try
-    {
-        if (!privateObject) {
-            ThrowMsg(ConversionException, "Object is null.");
+    try {
+        // Private Object
+        PushManager *priv = static_cast<PushManager *>(JSObjectGetPrivate(thisObject));
+        if (!priv) {
+            throw TypeMismatchException("Private object is NULL.");
         }
 
-        IPushManagerPtr pushManager = privateObject->getObject();
-
-        IEventDisconnectServicePtr dplEvent(new IEventDisconnectService());
-        dplEvent->setForSynchronousCall();
-
-        pushManager->disconnectService(dplEvent);
-    }
-    Catch(UnsupportedException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+        // perform
+        priv->disconnectService();
+
+        return JSValueMakeUndefined(context);
+    } catch (const BasePlatformException &err) {
+        LogError(err.getName() << ": " << err.getMessage());
+        return JSWebAPIError::throwException(context, exception, err);
+    } catch (...) {
+        DeviceAPI::Common::UnknownException err("Unknown Error in PushManager.disconnectService().");
+        LogError(err.getName() << ": " << err.getMessage());
+        return JSWebAPIError::throwException(context, exception, err);
     }
-    Catch(InvalidArgumentException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(ConversionException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(Exception)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
-    }
-
-    return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSPushManager::getRegistrationId(JSContextRef context,
@@ -448,62 +276,33 @@ JSValueRef JSPushManager::getRegistrationId(JSContextRef context,
         const JSValueRef arguments[],
         JSValueRef* exception)
 {
-    LogDebug("entered");
-
-    PushManagerPrivObject *privateObject =
-        static_cast<PushManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-
-    AceSecurityStatus status = PUSH_CHECK_ACCESS(PUSH_FUNCTION_API_GET_REGISTRATION_ID);
-
+    AceSecurityStatus status = PUSH_CHECK_ACCESS(PUSH_MANAGER_API_GET_REGISTRATION_ID);
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    Try
-    {
-        if (!privateObject) {
-            ThrowMsg(ConversionException, "Object is null.");
+    try {
+        // Private Object
+        PushManager *priv = static_cast<PushManager *>(JSObjectGetPrivate(thisObject));
+        if (!priv) {
+            throw TypeMismatchException("Private object is NULL.");
         }
 
-        IPushManagerPtr pushManager = privateObject->getObject();
-
-        IEventGetRegistrationIdPtr dplEvent(new IEventGetRegistrationId());
-        dplEvent->setForSynchronousCall();
-
-        pushManager->getRegistrationId(dplEvent);
-
-        if (dplEvent->getResult()) {
-            std::string id = dplEvent->getRegistrationId();
-            LogInfo("Got the registration id: "<<id);
-            if(id.empty()) {
-                return JSValueMakeNull(context);
-            } else {
-                PushConverter converter(context);
-                return converter.toJSValueRef(id);
-            }
+        // perform
+        std::string ret = priv->getRegistrationId();
+        if (ret.empty()) {
+            return JSValueMakeNull(context);
         } else {
-            ThrowMsg(UnknownException, "Failed getting registration id by unknown reason.");
+            return JSUtil::toJSValueRef(context, ret);
         }
-    }
-    Catch(UnsupportedException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(InvalidArgumentException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(ConversionException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(Exception)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+    } catch (const BasePlatformException &err) {
+        LogError(err.getName() << ": " << err.getMessage());
+        return JSWebAPIError::throwException(context, exception, err);
+    } catch (...) {
+        DeviceAPI::Common::UnknownException err("Unknown Error in PushManager.getRegistrationId().");
+        LogError(err.getName() << ": " << err.getMessage());
+        return JSWebAPIError::throwException(context, exception, err);
     }
 }
 
-}
-}
+
+} // Push
+} // DeviceAPI
old mode 100755 (executable)
new mode 100644 (file)
index fef61dd..888c08e
@@ -1,66 +1,36 @@
-/*
- * 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 _JS_TIZEN_PUSH_MANAGER_H_
-#define _JS_TIZEN_PUSH_MANAGER_H_
-
-#include <string>
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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_JS_PUSH_MANAGER_H__
+#define __TIZEN_JS_PUSH_MANAGER_H__
+
 #include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include "IPushManager.h"
-#include <CommonsJavaScript/JSCallbackManager.h>
+
+#include "PushManager.h"
 
 namespace DeviceAPI {
 namespace Push {
 
-#define TIZEN_PUSH_MANAGER_INTERFACE "PushManager"
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<IPushManagerPtr,
-                               WrtDeviceApis::CommonsJavaScript::NoOwnership> PushManagerPrivObject;
-
 class JSPushManager
 {
-  public:
-
+public:
     static const JSClassDefinition* getClassInfo();
-
     static const JSClassRef getClassRef();
-
-  private:
-
-    /**
-     * This member variable contains the values which has to be passed
-     * when the this class is embedded into JS Engine.
-     */
-    static JSClassDefinition m_classInfo;
-
-    /**
-     * This structure describes a statically declared function property.
-     */
-    static JSStaticFunction m_function[];
-
-    /**
-     * This member variable contains the initialization values for the
-     * properties of this class. The values are given according to
-     * the data structure JSPropertySpec
-     */
-    static JSStaticValue m_property[];
-
-    static JSClassRef m_jsClassRef;
+private:
 
     /**
      * The callback invoked when an object is first created.
@@ -73,9 +43,6 @@ class JSPushManager
      */
     static void finalize(JSObjectRef object);
 
-    /**
-     * Request push service registration.
-     */
     static JSValueRef registerService(JSContextRef context,
             JSObjectRef object,
             JSObjectRef thisObject,
@@ -83,9 +50,6 @@ class JSPushManager
             const JSValueRef arguments[],
             JSValueRef* exception);
 
-    /**
-     * Request push service unregistration.
-     */
     static JSValueRef unregisterService(JSContextRef context,
             JSObjectRef object,
             JSObjectRef thisObject,
@@ -93,9 +57,6 @@ class JSPushManager
             const JSValueRef arguments[],
             JSValueRef* exception);
 
-    /**
-     * Connect to the push service and receive notifications.
-     */
     static JSValueRef connectService(JSContextRef context,
             JSObjectRef object,
             JSObjectRef thisObject,
@@ -103,9 +64,6 @@ class JSPushManager
             const JSValueRef arguments[],
             JSValueRef* exception);
 
-    /**
-     * Disconnect to the push service and stop receiving notifications.
-     */
     static JSValueRef disconnectService(JSContextRef context,
             JSObjectRef object,
             JSObjectRef thisObject,
@@ -113,19 +71,37 @@ class JSPushManager
             const JSValueRef arguments[],
             JSValueRef* exception);
 
-    /**
-     * Get the push service registration id.
-     */
     static JSValueRef getRegistrationId(JSContextRef context,
             JSObjectRef object,
             JSObjectRef thisObject,
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+
+    /**
+     * This member variable contains the values which has to be passed
+     * when the this class is embedded into JS Engine.
+     */
+    static JSClassDefinition m_classInfo;
+
+    /**
+     * This structure describes a statically declared function property.
+     */
+    static JSStaticFunction m_function[];
+
+    /**
+     * This member variable contains the initialization values for the
+     * properties of this class. The values are given according to
+     * the data structure JSPropertySpec
+     */
+    static JSStaticValue m_property[];
+
+    static JSClassRef m_jsClassRef;
 };
 
-}
-}
 
-#endif /* _JS_TIZEN_PUSH_MANAGER_H_ */
 
+} // Push
+} // DeviceAPI
+
+#endif // __TIZEN_JS_DOWNLOAD_MANAGER_H__
index 0d836f9..0f6be88 100644 (file)
@@ -1,29 +1,34 @@
-/*
- * 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.
- */
-
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 <SecurityExceptions.h>
+
+#include <JSUtil.h>
+#include <JSWebAPIError.h>
+#include <ArgumentValidator.h>
+#include <GlobalContextManager.h>
+#include <MultiCallbackUserData.h>
+#include <PlatformException.h>
+
+#include "plugin_config.h"
 
 #include "JSPushMessage.h"
-#include <dpl/log/log.h>
-#include <JSTizenException.h>
-#include <JSTizenExceptionFactory.h>
-#include <CommonsJavaScript/Converter.h>
-#include "PushConverter.h"
 
 using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace DeviceAPI::Common;
 
 namespace DeviceAPI {
@@ -32,40 +37,27 @@ namespace Push {
 JSClassDefinition JSPushMessage::m_classInfo = {
     0,
     kJSClassAttributeNone,
-    TIZEN_PUSH_MESSAGE_INTERFACE,
-    NULL, //parentClass
-    m_property,
-    NULL, //staticValues,
-    initialize,
-    finalize,
-    NULL, //hasProperty,
-    NULL, //getProperty,
-    NULL, //setProperty,
-    NULL, //deleteProperty,
-    NULL, //getPropertyNames,
-    NULL, //callAsFunction,
-    NULL, //constructor,
-    NULL, //hasInstance,
-    NULL, //convertToType,
+    "PushMessage",
+    NULL, //ParentClass
+    NULL, //StaticValues
+    NULL, //StaticFunctions
+    initialize, //Initialize
+    finalize, //Finalize
+    NULL, //HasProperty,
+    NULL, //GetProperty,
+    NULL, //SetProperty,
+    NULL, //DeleteProperty,
+    NULL, //GetPropertyNames,
+    NULL, //CallAsFunction,
+    NULL, //CallAsConstructor,
+    NULL, //HasInstance,
+    NULL //ConvertToType
 };
 
-JSStaticValue JSPushMessage::m_property[] = {
-    { TIZEN_PUSH_MESSAGE_APP_DATA, getProperty, setProperty, kJSPropertyAttributeNone },
-    { TIZEN_PUSH_MESSAGE_ALERT_MESSAGE, getProperty, setProperty, kJSPropertyAttributeNone },
-    { TIZEN_PUSH_MESSAGE_DATE, getProperty, setProperty, kJSPropertyAttributeNone },
-
-    { 0, 0, 0, 0 }
-};
 
-JSClassRef JSPushMessage::m_jsClassRef = JSClassCreate(
-        JSPushMessage::getClassInfo());
+JSClassRef JSPushMessage::m_jsClassRef = JSClassCreate(JSPushMessage::getClassInfo());
 
-const JSClassDefinition* JSPushMessage::getClassInfo()
-{
-    return &(m_classInfo);
-}
-
-JSClassRef JSPushMessage::getClassRef()
+const JSClassRef JSPushMessage::getClassRef()
 {
     if (!m_jsClassRef) {
         m_jsClassRef = JSClassCreate(&m_classInfo);
@@ -73,139 +65,73 @@ JSClassRef JSPushMessage::getClassRef()
     return m_jsClassRef;
 }
 
-JSObjectRef JSPushMessage::createJSPushMessage(JSContextRef context, PushMessagePtr pushMessage)
+const JSClassDefinition* JSPushMessage::getClassInfo()
 {
-    PushMessagePrivateObject *priv = new PushMessagePrivateObject(context, pushMessage);
-    return JSObjectMake(context, getClassRef(), priv);
+    return &m_classInfo;
 }
 
-void JSPushMessage::initialize(JSContextRef context,
-        JSObjectRef object)
+void JSPushMessage::initialize(JSContextRef context, JSObjectRef object)
 {
     if (!JSObjectGetPrivate(object)) {
-        LogDebug("Create PushMessage private object.");
-        PushMessagePtr pushMessage( new PushMessage() );
-        PushMessagePrivateObject *priv = new PushMessagePrivateObject(context, pushMessage);
+        PushMessage *priv = new PushMessage();
         if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
             delete priv;
         }
-    } else {
-        LogDebug("Private object alrerady set.");
     }
 }
 
 void JSPushMessage::finalize(JSObjectRef object)
 {
-    PushMessagePrivateObject* priv = static_cast<PushMessagePrivateObject*>(JSObjectGetPrivate(object));
+    PushMessage *priv = static_cast<PushMessage *>(JSObjectGetPrivate(object));
     if (priv) {
-        LogDebug("Deleting PushMessage private object.");
-        delete priv;
         JSObjectSetPrivate(object, NULL);
+        delete priv;
     }
 }
 
-PushMessagePtr JSPushMessage::getPrivateObject(JSObjectRef object)
+PushMessage* JSPushMessage::getPrivateObject(JSContextRef context, JSObjectRef object)
 {
-    PushMessagePrivateObject *priv = static_cast<PushMessagePrivateObject*>(JSObjectGetPrivate(object));
+    PushMessage *priv = static_cast<PushMessage *>(JSObjectGetPrivate(object));
     if (!priv) {
-        ThrowMsg(NullPointerException, "Private object is null.");
+        throw TypeMismatchException("PushMessage's private object is NULL.");
     }
 
-    PushMessagePtr pushMessage = priv->getObject();
-    if (!pushMessage) {
-        ThrowMsg(NullPointerException, "PushMessage object is null.");
-    }
-    return pushMessage;
+    // appData
+    JSValueRef appData = JSUtil::getProperty(context, object, PUSH_MESSAGE_APP_DATA);
+    priv->setAppData(JSUtil::JSValueToString(context, appData));
+
+    // alertMessage
+    JSValueRef alertMessage = JSUtil::getProperty(context, object, PUSH_MESSAGE_ALERT_MESSAGE);
+    priv->setAlertMessage(JSUtil::JSValueToString(context, alertMessage));
+
+    // date
+    JSValueRef date = JSUtil::getProperty(context, object, PUSH_MESSAGE_DATE);
+    priv->setDate(JSUtil::JSValueToTimeT(context, date));
+
+    return priv;
 }
 
-void JSPushMessage::setPrivateObject(const PushMessagePtr &pushMessage,
-        JSContextRef ctx,
-        const JSObjectRef object)
+void JSPushMessage::setPrivateObject(JSContextRef context, JSObjectRef object, PushMessage *priv)
 {
-    Try
-    {
-        PushMessagePrivateObject *priv = static_cast<PushMessagePrivateObject*>(JSObjectGetPrivate(object));
-        delete priv;
-        priv = new PushMessagePrivateObject(ctx, pushMessage);
-        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
-            delete priv;
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("Error during setting PushMessage object.");
+    if (!priv) {
+        throw TypeMismatchException("PushMessage's private object is NULL.");
     }
-}
 
-JSValueRef JSPushMessage::getProperty(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-    LogDebug("enter");
+    JSObjectSetPrivate(object, static_cast<void*>(priv));
 
-    Try
-    {
-        PushMessagePrivateObject* priv = static_cast<PushMessagePrivateObject*>(JSObjectGetPrivate(object));
-        if (!priv) {
-            ThrowMsg(NullPointerException, "Private object is NULL.");
-        }
-        PushMessagePtr pushMessage = priv->getObject();
+    // appData
+    JSUtil::setProperty(context, object, PUSH_MESSAGE_APP_DATA,
+            JSUtil::toJSValueRef(context, priv->getAppData()), kJSPropertyAttributeNone);
 
-        PushConverter converter(context);
+    // alertMessage
+    JSUtil::setProperty(context, object, PUSH_MESSAGE_ALERT_MESSAGE,
+            JSUtil::toJSValueRef(context, priv->getAlertMessage()), kJSPropertyAttributeNone);
 
-        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PUSH_MESSAGE_APP_DATA)) {
-            return converter.toJSValueRef(pushMessage->getAppData());
-        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PUSH_MESSAGE_ALERT_MESSAGE)) {
-            return converter.toJSValueRef(pushMessage->getAlertMessage());
-        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PUSH_MESSAGE_DATE)) {
-            return converter.toJSValueRef((time_t)(pushMessage->getDate()));
-        }
-    }
-    Catch(Exception)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-    }
-    return JSValueMakeUndefined(context);
+    // date
+    JSUtil::setProperty(context, object, PUSH_MESSAGE_DATE,
+            JSUtil::makeDateObject(context, priv->getDate()), kJSPropertyAttributeNone);
 }
 
-bool JSPushMessage::setProperty(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef value,
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-
-    Try
-    {
-        PushMessagePrivateObject* priv =
-            static_cast<PushMessagePrivateObject*>(JSObjectGetPrivate(object));
-        if (!priv) {
-            ThrowMsg(NullPointerException, "PushMessage object is NULL.");
-        }
-        PushMessagePtr pushMessage = priv->getObject();
-
-        PushConverter converter(context);
-
-        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PUSH_MESSAGE_APP_DATA)) {
-            pushMessage->setAppData(converter.toString(value));
-            return true;
-        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PUSH_MESSAGE_ALERT_MESSAGE)) {
-            pushMessage->setAlertMessage(converter.toString(value));
-            return true;
-        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PUSH_MESSAGE_DATE)) {
-            pushMessage->setDate((long long int)(converter.toDateTimeT(value)));
-            return true;
-        }
-    }
-    Catch(Exception)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-    }
-    JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
-    return false;
-}
 
-}
-}
+} // Push
+} // DeviceAPI
old mode 100755 (executable)
new mode 100644 (file)
index f50911d..0850a94
@@ -1,95 +1,71 @@
-/*
- * 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 _JS_PUSH_MESSAGE_H_
-#define _JS_PUSH_MESSAGE_H_
-
-#include <string>
-#include <vector>
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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_JS_PUSH_MESSAGE_H__
+#define __TIZEN_JS_PUSH_MESSAGE_H__
+
 #include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
+
 #include "PushMessage.h"
 
 namespace DeviceAPI {
 namespace Push {
 
-#define TIZEN_PUSH_MESSAGE_INTERFACE "PushMessage"
-
-#define TIZEN_PUSH_MESSAGE_APP_DATA "appData"
-#define TIZEN_PUSH_MESSAGE_ALERT_MESSAGE "alertMessage"
-#define TIZEN_PUSH_MESSAGE_DATE "date"
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<PushMessagePtr,
-       WrtDeviceApis::CommonsJavaScript::NoOwnership> PushMessagePrivateObject;
-
 class JSPushMessage
 {
-  public:
-
+public:
     static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
 
-    static JSClassRef getClassRef();
-
-    static JSObjectRef createJSPushMessage(JSContextRef context, PushMessagePtr pushMessage);
-
-    static PushMessagePtr getPrivateObject(JSObjectRef object);
-
-    static void setPrivateObject(const PushMessagePtr &pushMessage,
-            JSContextRef ctx,
-            const JSObjectRef object);
-
-  private:
+    static PushMessage* getPrivateObject(JSContextRef context, JSObjectRef object);
+    static void setPrivateObject(JSContextRef context, JSObjectRef object, PushMessage *priv);
+private:
 
     /**
      * The callback invoked when an object is first created.
      */
-    static void initialize(JSContextRef context, JSObjectRef object);
+    static void initialize(JSContextRef context,
+            JSObjectRef object);
 
     /**
      * The callback invoked when an object is finalized.
      */
     static void finalize(JSObjectRef object);
 
-    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 JSClassRef m_jsClassRef;
-
     /**
-     * This structure contains properties and callbacks that define a type of object.
+     * This member variable contains the values which has to be passed
+     * when the this class is embedded into JS Engine.
      */
     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
+     * This member variable contains the initialization values for the
+     * properties of this class. The values are given according to
+     * the data structure JSPropertySpec
      */
     static JSStaticValue m_property[];
+
+    static JSClassRef m_jsClassRef;
 };
 
-}
-}
 
-#endif /* _JS_PUSH_MESSAGE_H_ */
+
+} // Push
+} // DeviceAPI
+
+#endif // __TIZEN_JS_DOWNLOAD_MANAGER_H__
diff --git a/src/Push/OnPushNotified.h b/src/Push/OnPushNotified.h
deleted file mode 100755 (executable)
index c720b12..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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 _ABSTRACT_LAYER_ON_PUSH_NOTIFIED_H_
-#define _ABSTRACT_LAYER_ON_PUSH_NOTIFIED_H_
-
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-#include <Commons/ListenerEvent.h>
-#include <Commons/Emitters.h>
-#include <string>
-
-#include "PushMessage.h"
-
-namespace DeviceAPI {
-namespace Push {
-
-class OnPushNotified : public WrtDeviceApis::Commons::ListenerEvent<OnPushNotified>
-{
-    bool m_result;
-    PushMessagePtr m_pushMessage;
-
-    public:
-    OnPushNotified() : m_result(false),
-        m_pushMessage(NULL)
-    {
-    }
-    ~OnPushNotified() {
-    }
-
-    void setResult (bool value) {
-        m_result = value;
-    }
-    bool getResult() const {
-        return m_result;
-    }
-
-    void setPushMessage(PushMessagePtr value)
-    {
-        m_pushMessage = value;
-    }
-    PushMessagePtr getPushMessage() const
-    {
-        return m_pushMessage;
-    }
-};
-
-typedef DPL::SharedPtr<OnPushNotified> OnPushNotifiedPtr;
-typedef WrtDeviceApis::Commons::ListenerEventEmitter<OnPushNotified> OnPushNotifiedEmitter;
-typedef DPL::SharedPtr<OnPushNotifiedEmitter> OnPushNotifiedEmitterPtr;
-
-}
-}
-
-#endif //_ABSTRACT_LAYER_ON_PUSH_NOTIFIED_H_
\ No newline at end of file
diff --git a/src/Push/PushAsyncCallbackManager.cpp b/src/Push/PushAsyncCallbackManager.cpp
deleted file mode 100755 (executable)
index 9984e29..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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 "PushAsyncCallbackManager.h"
-#include <dpl/singleton_impl.h>
-
-IMPLEMENT_SINGLETON(DeviceAPI::Push::PushAsyncCallbackManager)
-
diff --git a/src/Push/PushAsyncCallbackManager.h b/src/Push/PushAsyncCallbackManager.h
deleted file mode 100644 (file)
index 0ea1da0..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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_PUSH_ASYNC_CALLBACK_MANAGER_H_
-#define _TIZEN_PUSH_ASYNC_CALLBACK_MANAGER_H_
-
-#include <dpl/singleton.h>
-#include <AsyncCallbackManager.h>
-
-namespace DeviceAPI {
-namespace Push {
-
-class PushAsyncCallbackManager : public DeviceAPI::Common::AsyncCallbackManager
-{
-public:
-       PushAsyncCallbackManager()
-       {
-       }
-
-       virtual ~PushAsyncCallbackManager()
-       {
-       }
-
-       friend class DPL::Singleton<PushAsyncCallbackManager>;
-};
-
-typedef DPL::Singleton<PushAsyncCallbackManager> PushAsyncCallbackManagerSingleton;
-
-}
-}
-
-#endif // _TIZEN_PUSH_ASYNC_CALLBACK_MANAGER_H_
\ No newline at end of file
diff --git a/src/Push/PushConverter.cpp b/src/Push/PushConverter.cpp
deleted file mode 100755 (executable)
index d688aa2..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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 <dpl/log/log.h>
-#include <CommonsJavaScript/Validator.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include "JSPushManager.h"
-#include "PushConverter.h"
-
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace DeviceAPI {
-namespace Push {
-
-PushConverter::PushConverter(JSContextRef context) : Converter(context)
-{
-}
-
-PushConverter::~PushConverter()
-{
-}
-
-JSValueRef PushConverter::toFunctionOrNull(const JSValueRef& arg)
-{
-    if (Validator(m_context).isCallback(arg)) {
-        return arg;
-    } else if (!JSValueIsNull(m_context, arg) && !JSValueIsUndefined(m_context, arg)) {
-        ThrowMsg(ConversionException, "Not a function nor JS null.");
-    }
-    return NULL;
-}
-
-JSValueRef PushConverter::toFunction(const JSValueRef& arg)
-{
-    if (Validator(m_context).isCallback(arg)) {
-        return arg;
-    }
-    ThrowMsg(ConversionException, "Not a function.");
-}
-
-}
-}
diff --git a/src/Push/PushConverter.h b/src/Push/PushConverter.h
deleted file mode 100755 (executable)
index bcd00be..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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 _JS_TIZEN_PUSH_CONVERTER_H_
-#define _JS_TIZEN_PUSH_CONVERTER_H_
-
-#include <string>
-#include "IPushManager.h"
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/ScopedJSStringRef.h>
-
-namespace DeviceAPI {
-namespace Push {
-
-class PushConverter : public WrtDeviceApis::CommonsJavaScript::Converter
-{
-  public:
-    explicit PushConverter(JSContextRef context);
-    virtual ~PushConverter();
-
-    /**
-     * @throw InvalidArgumentException If not a callback nor JS null.
-     */
-    JSValueRef toFunctionOrNull(const JSValueRef& arg);
-
-    /**
-     * @throw ConversionException If JS null.
-     * @throw InvalidArgumentException If not a callback nor JS null.
-     */
-    JSValueRef toFunction(const JSValueRef& arg);
-};
-
-}
-}
-
-#endif /* _JS_TIZEN_PUSH_CONVERTER_H_ */
diff --git a/src/Push/PushListenerManager.cpp b/src/Push/PushListenerManager.cpp
deleted file mode 100755 (executable)
index e67005e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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 "PushListenerManager.h"
-#include <dpl/singleton_impl.h>
-
-IMPLEMENT_SINGLETON(DeviceAPI::Push::PushListenerManager)
-
diff --git a/src/Push/PushListenerManager.h b/src/Push/PushListenerManager.h
deleted file mode 100644 (file)
index 8edf017..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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_PUSH_LISTENER_MANAGER_H_
-#define _TIZEN_PUSH_LISTENER_MANAGER_H_
-
-#include <map>
-#include <JavaScriptCore/JavaScript.h>
-#include <dpl/log/log.h>
-#include <dpl/shared_ptr.h>
-#include <dpl/singleton.h>
-#include <IListenerManager.h>
-#include "PushResponseDispatcher.h"
-#include "JSPushManager.h"
-#include "IPushManager.h"
-
-namespace DeviceAPI {
-namespace Push {
-
-class PushListenerManager : public DeviceAPI::Common::IListenerController
-{
-public:
-       PushListenerManager()
-       {
-       }
-
-       virtual ~PushListenerManager()
-       {
-       }
-};
-typedef DPL::Singleton<PushListenerManager> PushListenerManagerSingleton;
-
-class PushListenerCanceller : public DeviceAPI::Common::IListenerItem
-{
-public:
-       PushListenerCanceller(JSContextRef context, JSObjectRef object, long watchId) :
-               DeviceAPI::Common::IListenerItem(context, object, watchId)
-       {
-       }
-
-       virtual ~PushListenerCanceller()
-       {
-       }
-
-       virtual void cancelListener()
-       {
-               PushManagerPrivObject *privateObject = static_cast<PushManagerPrivObject*>(JSObjectGetPrivate(m_object));
-               if (!privateObject) {
-                       LogWarning("Object is null.");
-                       return;
-               }
-
-               IPushManagerPtr pushManager = privateObject->getObject();
-
-               Try {
-                       LogDebug("Removing notification listener for push operation with id: "<<m_watchId);
-                       IEventDisconnectServicePtr dplEvent(new IEventDisconnectService());
-                       dplEvent->setForSynchronousCall();
-                       pushManager->disconnectService(dplEvent);
-               } Catch(WrtDeviceApis::Commons::Exception) {
-                       LogError("Error on platform : " << _rethrown_exception.GetMessage());
-               }
-       }
-};
-typedef DPL::SharedPtr<PushListenerCanceller> PushListenerCancellerPtr;
-
-}
-}
-
-#endif // _TIZEN_PUSH_LISTENER_MANAGER_H_
\ No newline at end of file
index 32c6794..f2b535b 100644 (file)
@@ -1,36 +1,86 @@
-/*
- * 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.
- */
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 <JSUtil.h>
+#include <JSWebAPIError.h>
+#include <PlatformException.h>
 
+#include <app_manager.h>
 
-#include "PushManager.h"
+#include "JSPushMessage.h"
 #include "PushMessage.h"
-#include <dpl/log/log.h>
-#include <ApplicationControl.h>
-#include <app_manager.h>
-#include <unistd.h>
+#include "PushManager.h"
 
-#include "app.h"
+#include <Logger.h>
 
-using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
 
 namespace DeviceAPI {
 namespace Push {
 
+static std::string _get_internal_error(int err)
+{
+    bool success = false;
+    std::string msg = "";
+
+    switch (err) {
+        case PUSH_ERROR_INVALID_PARAMETER:
+            msg = "Invalid parameter";
+            break;
+        case PUSH_ERROR_OUT_OF_MEMORY:
+            msg = "Out of memory";
+            break;
+        case PUSH_ERROR_NOT_CONNECTED:
+            msg = "Network is unreachable";
+            break;
+        case PUSH_ERROR_NO_DATA:
+            msg = "No data available";
+            break;
+        case PUSH_ERROR_OPERATION_FAILED:
+            msg = "Internal operation failed";
+            break;
+        case SERVICE_ERROR_APP_NOT_FOUND:
+            msg = "The application was not found";
+            break;
+        case SERVICE_ERROR_KEY_NOT_FOUND:
+            msg = "Specified key not found";
+            break;
+        case SERVICE_ERROR_KEY_REJECTED:
+            msg = "Not available key";
+            break;
+        case SERVICE_ERROR_INVALID_DATA_TYPE:
+            msg = "Invalid data type";
+            break;
+        case PUSH_ERROR_NONE:
+            success = true;
+            break;
+
+        default:
+            msg = "Unknown error";
+    }
 
-void get_param(const char *msg, const char *name, char **value)
+    if (!success) {
+        LogError("Platform error %d <%s>", err, msg.c_str());
+    }
+
+    return msg;
+}
+
+static void get_param(const char *msg, const char *name, char **value)
 {
     int step = 0;
     int pos = 0;
@@ -97,205 +147,202 @@ void get_param(const char *msg, const char *name, char **value)
     }
 }
 
-
-static void push_registration_result_cb(push_result_e result, const char *msg, void *user_data)
+static int get_current_app_id_and_pkg_id(char **app_id, char **pkg_id)
 {
-    LogInfo("Push registration result cb with msg: "<<msg);
-
-    PushManager* thisPushManager = (PushManager*) user_data;
-
-    Try
-    {
-        if(PUSH_RESULT_SUCCESS==result) {
-            int ret;
-            char* regstrationId = NULL;
-            ret = push_get_registration_id(thisPushManager->m_connectionHandle, &regstrationId);
-            if(PUSH_ERROR_NONE!=ret) {
-                ThrowMsg(UnknownException, "Can't get the registration id.");
-            } else {
-                LogDebug("Registration id: "<<regstrationId);
-            }
-
-            thisPushManager->m_registerService->setResult(true);
-            thisPushManager->m_registerService->setRegistrationId(regstrationId);
+    LogDebug("get_current_pkg_id enter");
+    int parent_pid = getppid();
+    LogDebug("parent pid : " << parent_pid);
+    char *_app_id = NULL;
+    char *_pkg_id = NULL;
 
-            thisPushManager->manualAnswerRegisterService();
+    app_info_h handle;
 
-            if(regstrationId) {
-                free(regstrationId);
-            }
-        } else {
-            ThrowMsg(UnknownException, "Error in registration result cb with result: "<<result);
-        }
+    int ret = app_manager_get_app_id(parent_pid, &_app_id);
+    if ((ret != APP_MANAGER_ERROR_NONE) || (_app_id == NULL)) {
+        LogDebug("Cannot get app id from pid : " << parent_pid);
+        return ret;
+    } else {
+        LogDebug("app_id : " << _app_id);
     }
-    Catch (Exception)
+
+    ret = app_manager_get_app_info(_app_id, &handle);
+    if (ret != APP_MANAGER_ERROR_NONE)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        thisPushManager->m_registerService->setResult(false);
-        thisPushManager->manualAnswerRegisterService();
+        LogDebug("Fail to get appinfo by " << _app_id);
+        return ret;
     }
-}
 
-static void push_unregistration_result_cb(push_result_e result, const char *msg, void *user_data)
-{
-    LogInfo("Push unregistration result cb with msg: "<<msg);
-
-    PushManager* thisPushManager = (PushManager*) user_data;
-
-    Try
+    ret = app_info_get_package(handle, &_pkg_id);
+    if ((ret != APP_MANAGER_ERROR_NONE) || (_pkg_id == NULL))
     {
-        if(PUSH_RESULT_SUCCESS==result) {
-            thisPushManager->m_unregisterService->setResult(true);
-            thisPushManager->manualAnswerUnregisterService();
-        } else {
-            ThrowMsg(UnknownException, "Error in restration result cb with result: "<<result);
-        }
+        LogDebug("Fail to get pkg_id by " << _app_id);
     }
-    Catch (Exception)
+
+    ret = app_info_destroy(handle);
+    if (ret != APP_MANAGER_ERROR_NONE)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        thisPushManager->manualAnswerUnregisterService();
+        LogDebug("Fail to get destory appinfo");
+        return ret;
     }
+
+    *app_id = _app_id;
+    *pkg_id = _pkg_id;
+
+    return ret;
 }
 
 static void push_connection_state_cb(push_state_e state, const char *err, void *user_data)
 {
-    LogInfo("Push connection state cb with state: "<<state<<", err: "<<err);
+    LogInfo("Push connection state cb with state: "<< state <<", err: "<< err);
 
-    Try
-    {
-        PushManager* thisPushManager = (PushManager*) user_data;
-
-        thisPushManager->m_connectionState = state;
-    }
-    Catch (Exception)
-    {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+    PushManager *thisPushManager = static_cast<PushManager*>(user_data);
+    if (!thisPushManager) {
+        LogError("user_data of push_connection_state_cb() is NULL.");
     }
+    thisPushManager->m_connectionState = state;
 }
 
 static void push_notify_cb(push_notification_h noti, void *user_data)
 {
+    int ret;
+    char *appData = NULL;
+    char *rawMessage = NULL;
+    char *alertMessage = NULL;
+    long long int date = -1;
+
     LogInfo("Push notification cb");
 
-    Try
-    {   
-        OnPushNotifiedPtr eventPtr(new OnPushNotified());
-        PushManager* thisPushManager = (PushManager*) user_data;
-        int ret;
+    try {
+        PushManager *thisPushManager = static_cast<PushManager*>(user_data);
+        if (!thisPushManager) {
+            throw UnknownException("user_data of push_notify_cb() is NULL.");
+        }
 
-        char* appData = NULL;
-        char* rawMessage = NULL;
-        char* alertMessage = NULL;
-        long long int date = UNDEFINED_DATE;
+        MultiCallbackUserDataPtr callback = thisPushManager->m_notificationCallback;
+        if (!callback) {
+            LogWarning("notification callback is not set. ignored.");
+            return;
+        }
 
         ret = push_get_notification_data(noti, &appData);
-        if (PUSH_ERROR_NONE!=ret) {
-            LogError("Error while getting appData: "<<ret);
+        if (ret != PUSH_ERROR_NONE) {
+            throw UnknownException(("Platform error while getting notification data. " + _get_internal_error(ret)).c_str());
         }
 
         ret = push_get_notification_message(noti, &rawMessage);
-        if (PUSH_ERROR_NONE!=ret) {
-            LogError("Error while getting raw message: "<<ret);
+        if (ret != PUSH_ERROR_NONE) {
+            throw UnknownException(("Platform error while getting notification message. " + _get_internal_error(ret)).c_str());
         } else {
             get_param(rawMessage, "alertMessage", &alertMessage);
-            if (alertMessage == NULL) {
-                LogError("Error while getting alertMessage: rawMessage = " << rawMessage);
+            if (!alertMessage) {
+                throw UnknownException(("Platform error while getting alert message from raw message. " + _get_internal_error(ret)).c_str());
             }
             free(rawMessage);
         }
 
         ret = push_get_notification_time(noti, &date);
-        if (PUSH_ERROR_NONE!=ret) {
-            LogError("Error while getting date: "<<ret);
+        if (ret != PUSH_ERROR_NONE) {
+            LogError("Platform error while getting notification date/time. " << _get_internal_error(ret));
         }
 
-        PushMessagePtr pushMessage(new PushMessage());
-        if(appData) {
+        PushMessage *pushMessage = new PushMessage();
+        if (appData) {
             pushMessage->setAppData(appData);
+            free(appData);
         }
-        if(alertMessage) {
+        if (alertMessage) {
             pushMessage->setAlertMessage(alertMessage);
+            free(alertMessage);
         }
-        if(UNDEFINED_DATE!=date) {
-            pushMessage->setDate(date);
+        if (date >= 0) {
+            pushMessage->setDate((time_t)date);
         }
 
-        LogInfo("Noti appData: "<<pushMessage->getAppData()<<", alertMessage: "<<pushMessage->getAlertMessage()<<", date: "<<pushMessage->getDate());
-
-        free(appData);
-        free(alertMessage);
-
-        eventPtr->setPushMessage(pushMessage);
-        eventPtr->setResult(true);
+        JSObjectRef pushMessageObj = JSObjectMake(callback->getContext(), JSPushMessage::getClassRef(), NULL);
+        JSPushMessage::setPrivateObject(callback->getContext(), pushMessageObj, pushMessage);
 
-        if (thisPushManager->m_emitter) {
-            LogInfo("Emitting the push noti...");
-            thisPushManager->m_emitter->emit(eventPtr);
-        } else {
-            LogInfo("Ingore the push noti.");
-        }
-    }
-    Catch (Exception)
-    {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        callback->invokeCallback("onsuccess", pushMessageObj);
+    } catch (const BasePlatformException &err) {
+        LogError(err.getMessage());
     }
 }
- static int get_current_app_id_and_pkg_id(char **app_id, char **pkg_id)
+
+static void push_registration_result_cb(push_result_e result, const char *msg, void *user_data)
 {
-    LogDebug("get_current_pkg_id enter");
-    int parent_pid = getppid();
-    LogDebug("parent pid : " << parent_pid);
-    char *_app_id = NULL;
-    char *_pkg_id = NULL;
+    int ret;
+    char *tmp = NULL;
 
-    app_info_h handle;
+    LogInfo("Push registration cb");
 
-    int ret = app_manager_get_app_id(parent_pid, &_app_id);
-    if ((ret != APP_MANAGER_ERROR_NONE) || (_app_id == NULL)) {
-        LogDebug("Cannot get app id from pid : " << parent_pid);
-        return ret;
-    } else {
-        LogDebug("app_id : " << *_app_id);
-    }
+    try {
+        PushManager *thisPushManager = static_cast<PushManager*>(user_data);
+        if (!thisPushManager) {
+            throw UnknownException("user_data of push_registration_result_cb() is NULL.");
+        }
 
-    ret = app_manager_get_app_info(_app_id, &handle);
-    if (ret != APP_MANAGER_ERROR_NONE)
-    {
-        LogDebug("Fail to get appinfo by " << _app_id);
-        return ret;
-    }
+        MultiCallbackUserDataPtr callback = thisPushManager->m_registrationCallback;
+        if (!callback) {
+            throw UnknownException("the callback for registration is NULL.");
+        }
 
-    ret = app_info_get_package(handle, &_pkg_id);
-    if ((ret != APP_MANAGER_ERROR_NONE) || (_pkg_id == NULL))
-    {
-        LogDebug("Fail to get pkg_id by " << _app_id);
+        if (result == PUSH_RESULT_SUCCESS) {
+            ret = push_get_registration_id(thisPushManager->m_connectionHandle, &tmp);
+            if (PUSH_ERROR_NONE != ret) {
+                throw UnknownException("Platform error while getting registration id.");
+            }
+            if (tmp) {
+                std::string registrationId(tmp);
+                callback->invokeCallback("onsuccess", JSUtil::toJSValueRef(callback->getContext(), registrationId));
+                free(tmp);
+            }
+        } else {
+            UnknownException error(msg);
+            JSObjectRef errorObj = JSWebAPIError::makeJSWebAPIError(callback->getContext(), error);
+            callback->invokeCallback("onerror", errorObj);
+        }
+    } catch (const BasePlatformException &err) {
+        LogError(err.getMessage());
     }
+}
 
-    ret = app_info_destroy(handle);
-    if (ret != APP_MANAGER_ERROR_NONE)
-    {
-        LogDebug("Fail to get destory appinfo");
-        return ret;
-    }
+static void push_unregistration_result_cb(push_result_e result, const char *msg, void *user_data)
+{
+    LogInfo("Push unregistration cb");
 
-    *app_id = _app_id;
-    *pkg_id = _pkg_id;
+    try {
+        PushManager *thisPushManager = static_cast<PushManager*>(user_data);
+        if (!thisPushManager) {
+            throw UnknownException("user_data of push_unregistration_result_cb() is NULL.");
+        }
 
-    return ret;
+        MultiCallbackUserDataPtr callback = thisPushManager->m_unregistrationCallback;
+        if (!callback) {
+            throw UnknownException("the callback for unregistration is NULL.");
+        }
+
+        if (result == PUSH_RESULT_SUCCESS) {
+            callback->invokeCallback("onsuccess");
+        } else {
+            UnknownException error(msg);
+            JSObjectRef errorObj = JSWebAPIError::makeJSWebAPIError(callback->getContext(), error);
+            callback->invokeCallback("onerror", errorObj);
+        }
+    } catch (const BasePlatformException &err) {
+        LogError(err.getMessage());
+    }
 }
 
-PushManager::PushManager() : m_appId(NULL),
+PushManager::PushManager():
     m_pkgId(NULL),
+    m_appId(NULL),
     m_connectionState(PUSH_STATE_UNREGISTERED),
-    m_connectionHandle(NULL),
-    m_emitter(NULL)
+    m_connectionHandle(NULL)
 {
     LogInfo("Connecting to the push service...");
     int ret;
 
     ret = get_current_app_id_and_pkg_id(&m_appId, &m_pkgId);
-    if (APP_ERROR_NONE!=ret) {
+    if (APP_ERROR_NONE != ret) {
         LogError("Error while getting app id: "<<ret);
         return;
     }
@@ -305,7 +352,7 @@ PushManager::PushManager() : m_appId(NULL),
 
     ret = push_connect(m_pkgId, push_connection_state_cb, push_notify_cb, this, &m_connectionHandle);
     if (PUSH_ERROR_NONE!=ret) {
-        LogError("Error while connecting to the push service: "<<ret);
+        LogError("Error while connecting to the push service: "<< ret);
         return;
     }
 }
@@ -325,130 +372,82 @@ PushManager::~PushManager()
     push_disconnect(m_connectionHandle);
 }
 
-void PushManager::manualAnswerRegisterService()
-{
-    Try
-    {
-        LogInfo("Manual answer for register service.");
-        EventRequestReceiver<IEventRegisterService>::ManualAnswer(m_registerService);
-    }
-    Catch(Exception)
-    {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-    }
+PushManager *PushManager::getInstance() {
+    LogInfo("Getting instance of PushManager...");
+    static PushManager instance;
+    return &instance;
 }
 
-void PushManager::manualAnswerUnregisterService()
+void PushManager::registerService(ApplicationControlPtr appControl, MultiCallbackUserDataPtr callback)
 {
-    Try
-    {
-        LogInfo("Manual answer for unregister service.");
-        EventRequestReceiver<IEventUnregisterService>::ManualAnswer(m_unregisterService);
-    }
-    Catch(Exception)
-    {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-    }
-}
-
-void PushManager::OnRequestReceived(const IEventConnectServicePtr &event)
-{
-    Try
-    {
-        LogInfo("Attaching the emitter...");
-        m_emitter = event->getEmitter();
-        event->setResult(true);
-    }
-    Catch(Exception)
-    {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        event->setResult(false);
-        event->setExceptionCode(ExceptionCodes::UnknownException);
-    }
-}
+    int ret;
+    service_h service;
 
-void PushManager::OnRequestReceived(const IEventDisconnectServicePtr &event)
-{
-    Try
-    {
-        LogInfo("Dettaching the emitter...");
-        m_emitter = OnPushNotifiedEmitterPtr(NULL);
-        event->setResult(true);
-    }
-    Catch(Exception)
-    {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        event->setResult(false);
-        event->setExceptionCode(ExceptionCodes::UnknownException);
+    ret = service_create(&service);
+    if (ret != SERVICE_ERROR_NONE) {
+        throw UnknownException(("Platform error while creating service. " + _get_internal_error(ret)).c_str());
     }
-}
 
-void PushManager::OnRequestReceived(const IEventRegisterServicePtr &event)
-{
-    Try
-    {
-        LogInfo("Registering to the push service...");
-        int ret;
-
-        event->switchToManualAnswer();
-        m_registerService = event;
-
-        // Prepare the application control inforamtion.
-        DeviceAPI::Application::ApplicationControlPtr appControl = event->getApplicationControl();
-        if(appControl == NULL) {
-            ThrowMsg(InvalidArgumentException, "App control is NULL.");
-        }
-
-        service_h service;
-        service_create(&service);
-        if (appControl->getOperation().compare("") != 0) {
-            LogDebug("operation: "<<appControl->getOperation());
-            service_set_operation(service, appControl->getOperation().c_str());
-        } else {
-            ThrowMsg(InvalidArgumentException, "Operation is invalid.");
+    if (appControl->getOperation().compare("") != 0) {
+        ret = service_set_operation(service, appControl->getOperation().c_str());
+        if (ret != SERVICE_ERROR_NONE) {
+            throw UnknownException(("Platform error while setting operation to appControl. " + _get_internal_error(ret)).c_str());
         }
+    } else {
+        throw InvalidValuesException("the operation of application control is invalid.");
+    }
 
-        if (appControl->getUri().compare("") != 0) {
-            LogDebug("uri: "<<appControl->getUri());
-            service_set_uri(service, appControl->getUri().c_str());
+    if (appControl->getUri().compare("") != 0) {
+        ret = service_set_uri(service, appControl->getUri().c_str());
+        if (ret != SERVICE_ERROR_NONE) {
+            LogWarning("Platform error while setting uri to appControl. " << _get_internal_error(ret));
         }
+    }
 
-        if (appControl->getMime().compare("") != 0) {
-            LogDebug("mime: "<<appControl->getMime());
-            service_set_mime(service, appControl->getMime().c_str());
+    if (appControl->getMime().compare("") != 0) {
+        ret = service_set_mime(service, appControl->getMime().c_str());
+        if (ret != SERVICE_ERROR_NONE) {
+            LogWarning("Platform error while setting mime to appControl. " << _get_internal_error(ret));
         }
+    }
 
-        service_set_app_id(service, m_appId);
-
-        LogDebug("Handling application control data array...");
-        std::vector<DeviceAPI::Application::ApplicationControlDataPtr> controlDataArray = appControl->getAppControlDataArray();
-
-        if (!controlDataArray.empty()) {
-            std::string key;
-            const char** arr = NULL;
-            LogDebug("controlDataArray.size(): "<<controlDataArray.size());
+    ret = service_set_app_id(service, m_appId);
+    if (ret != SERVICE_ERROR_NONE) {
+        throw UnknownException(("Platform error while setting appId to appControl. " + _get_internal_error(ret)).c_str());
+    }
 
-            for (size_t i = 0; i < controlDataArray.size(); ++i) {
-                key = controlDataArray.at(i)->getKey();
-                LogDebug("key: [" << key << "]");
-                if (key.empty()) {
-                    ThrowMsg(InvalidArgumentException, "Invalid key for "<<i);
-                }
+    std::vector<ApplicationControlDataPtr> controlDataArray = appControl->getAppControlDataArray();
+    if (!controlDataArray.empty()) {
+        std::string key;
+        const char **arr = NULL;
 
+        for (size_t i = 0; i < controlDataArray.size(); i++) {
+            key = controlDataArray.at(i)->getKey();
+            if (key.empty()) {
+                LogWarning("Invalid key for " << i << " in ApplicationControl's data array.");
+            } else {
                 std::vector<std::string> valueArray = controlDataArray.at(i)->getValue();
                 size_t size = valueArray.size();
 
                 arr = (const char**)calloc(sizeof(char*), size);
+                if (arr == NULL) {
+                    throw UnknownException("Out of Memory: Can't allocate value array for ApplicationControl's data");
+                }
 
                 for (size_t j = 0; j < size; j++) {
                     arr[j] = valueArray.at(j).c_str();
-                    LogDebug("arr["<<j<<"]: [" <<arr[j] << "]");
                 }
 
-                if(size==1){
-                    service_add_extra_data(service, (const char*)key.c_str(), arr[0]);
-                }else{
-                    service_add_extra_data_array(service, (const char*)key.c_str(), arr, size);
+                if (size == 1) {
+                    ret = service_add_extra_data(service, (const char*)key.c_str(), arr[0]);
+                    if (ret != SERVICE_ERROR_NONE) {
+                        LogWarning("Platform error while adding extra data to appControl. " << _get_internal_error(ret));
+                    }
+                } else {
+                    ret = service_add_extra_data_array(service, (const char*)key.c_str(), arr, size);
+                    if (ret != SERVICE_ERROR_NONE) {
+                        LogWarning("Platform error while adding extra data array to appControl. " << _get_internal_error(ret));
+                    }
                 }
 
                 if (arr) {
@@ -456,81 +455,63 @@ void PushManager::OnRequestReceived(const IEventRegisterServicePtr &event)
                 }
             }
         }
+    }
 
-        LogDebug("Requesting push service registration...");
-        ret = push_register(m_connectionHandle, service, push_registration_result_cb, this);
-        if (PUSH_ERROR_NONE!=ret) {
-            if(PUSH_ERROR_NOT_CONNECTED==ret) {
-                LogWarning("Not connected.");
-            }
-            service_destroy(service);
-            ThrowMsg(UnknownException, "Error while registering to the push service: "<<ret);
-        }
+    m_registrationCallback = callback;
 
+    ret = push_register(m_connectionHandle, service, push_registration_result_cb, this);
+    if (ret != PUSH_ERROR_NONE) {
         service_destroy(service);
+        throw UnknownException(("Platform error while registering the application to the push service. " + _get_internal_error(ret)).c_str());
     }
-    Catch(Exception)
-    {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        event->setResult(false);
-        event->setExceptionCode(ExceptionCodes::UnknownException);
-        EventRequestReceiver<IEventRegisterService>::ManualAnswer(event);
-    }
+
+    service_destroy(service);
 }
 
-void PushManager::OnRequestReceived(const IEventUnregisterServicePtr &event)
+void PushManager::unregisterService(MultiCallbackUserDataPtr callback)
 {
-    Try
-    {
-        LogDebug("Unregistering the push service...");
-        int ret;
+    int ret;
 
-        event->switchToManualAnswer();
-        m_unregisterService = event;
+    m_unregistrationCallback = callback;
 
-        ret = push_deregister(m_connectionHandle, push_unregistration_result_cb, this);
-        if (PUSH_ERROR_NONE!=ret) {
-            ThrowMsg(UnknownException, "Error while unregistering the push service: "<<ret);
-        }
+    ret = push_deregister(m_connectionHandle, push_unregistration_result_cb, this);
+    if (ret != PUSH_ERROR_NONE) {
+        throw UnknownException(("Platform error while unregistering the application from the push service. " + _get_internal_error(ret)).c_str());
     }
-    Catch(Exception)
-    {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        event->setResult(false);
-        event->setExceptionCode(ExceptionCodes::UnknownException);
-        EventRequestReceiver<IEventUnregisterService>::ManualAnswer(event);
+}
+
+void PushManager::connectService(MultiCallbackUserDataPtr notificationCallback)
+{
+    if (notificationCallback) {
+        m_notificationCallback = notificationCallback;
+    } else {
+        throw UnknownException("notificationCallback of arguments is NULL.");
     }
 }
 
-void PushManager::OnRequestReceived(const IEventGetRegistrationIdPtr &event)
+void PushManager::disconnectService()
 {
-    LogDebug("entered");
+    m_notificationCallback.reset();
+}
 
-    Try
-    {
-        int ret;
-        char* regstrationId = NULL;
-        ret = push_get_registration_id(m_connectionHandle, &regstrationId);
-        if(PUSH_ERROR_NONE!=ret) {
-            LogDebug("No registration id available with error code: " << ret);
-        } else {
-            LogDebug("Registration id: "<<regstrationId);
-            event->setRegistrationId(regstrationId);
-        }
+std::string PushManager::getRegistrationId()
+{
+    int ret;
+    char *regId = NULL;
+    std::string str = "";
 
-        if(regstrationId) {
-            free(regstrationId);
+    ret = push_get_registration_id(m_connectionHandle, &regId);
+    if (ret != PUSH_ERROR_NONE) {
+        LogWarning("Platform error while getting registration id. " << _get_internal_error(ret));
+    } else {
+        if (regId) {
+            str = regId;
+            free(regId);
         }
-
-        event->setResult(true);
-    }
-    Catch(Exception)
-    {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        event->setResult(false);
-        event->setExceptionCode(ExceptionCodes::UnknownException);
     }
-}
 
+    return str;
 }
-}
+
+} // Push
+} // DeviceAPI
old mode 100755 (executable)
new mode 100644 (file)
index 71ef948..bf018b6
@@ -1,59 +1,66 @@
-/*
- * 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 _PLATFORM_PUSH_MANAGER_H_
-#define _PLATFORM_PUSH_MANAGER_H_
-
-#include "IPushManager.h"
-#include "OnPushNotified.h"
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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_PUSH_MANAGER_H__
+#define __TIZEN_PUSH_MANAGER_H__
+
+#include <MultiCallbackUserData.h>
+
+#include <JSApplicationControl.h>
 
 #include <push.h>
 
+#include "PushTypes.h"
+
+using namespace DeviceAPI::Common;
+using namespace DeviceAPI::Application;
+
 namespace DeviceAPI {
 namespace Push {
 
-class PushManager : public IPushManager
+class PushManager
 {
-  public:
+public:
+    void registerService(ApplicationControlPtr appControl, MultiCallbackUserDataPtr callback);
+    void unregisterService(MultiCallbackUserDataPtr callback);
+    void connectService(MultiCallbackUserDataPtr notificationCallback);
+    void disconnectService();
+    std::string getRegistrationId();
+
+    static PushManager* getInstance();
+
+private:
     PushManager();
     virtual ~PushManager();
 
-    char* m_appId;
-    char* m_pkgId;
-    push_state_e m_connectionState;
+public:
+       push_state_e m_connectionState;
     push_connection_h m_connectionHandle;
-    OnPushNotifiedEmitterPtr m_emitter;
-
-    // Pointers for manual answer.
-    IEventRegisterServicePtr m_registerService;
-    IEventUnregisterServicePtr m_unregisterService;
+    MultiCallbackUserDataPtr m_registrationCallback;
+    MultiCallbackUserDataPtr m_unregistrationCallback;
+    MultiCallbackUserDataPtr m_notificationCallback;
 
-    void manualAnswerRegisterService();
-    void manualAnswerUnregisterService();
+private:
+    char *m_appId;
+    char *m_pkgId;
 
-  protected:
-    virtual void OnRequestReceived(const IEventRegisterServicePtr &event);
-    virtual void OnRequestReceived(const IEventUnregisterServicePtr &event);
-    virtual void OnRequestReceived(const IEventConnectServicePtr &event);
-    virtual void OnRequestReceived(const IEventDisconnectServicePtr &event);
-    virtual void OnRequestReceived(const IEventGetRegistrationIdPtr &event);
 };
 
-}
-}
+} // Push
+} // DeviceAPI
 
-#endif /* _PLATFORM_PUSH_MANAGER_H_ */
+#endif // __TIZEN_PUSH_MANAGER_H__
old mode 100755 (executable)
new mode 100644 (file)
index 72cdf69..356f6f6
@@ -1,21 +1,22 @@
-/*
- * 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.
- */
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 <dpl/log/log.h>
+#include <PlatformException.h>
+#include <Logger.h>
 
 #include "PushMessage.h"
 
@@ -24,18 +25,10 @@ namespace Push {
 
 PushMessage::PushMessage():
     m_appData(""),
-    m_alertMessage(""),
-    m_date(UNDEFINED_DATE)
+    m_alertMessage("")
 {
 }
 
-PushMessage::PushMessage(std::string appData, std::string alertMessage, long long int date)
-{
-    m_appData = appData;
-    m_alertMessage = alertMessage;
-    m_date = date;
-}
-
 PushMessage::~PushMessage()
 {
 }
@@ -60,15 +53,16 @@ void PushMessage::setAlertMessage(std::string alertMessage)
     m_alertMessage = alertMessage;
 }
 
-long long int PushMessage::getDate() const
+time_t PushMessage::getDate() const
 {
     return m_date;
 }
 
-void PushMessage::setDate(long long int date)
+void PushMessage::setDate(time_t date)
 {
     m_date = date;
 }
 
-}
-}
+
+} // Push
+} // DeviceAPI
old mode 100755 (executable)
new mode 100644 (file)
index d77d112..2e6b233
@@ -1,56 +1,54 @@
-/*
- * 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 _ABSTRACT_LAYER_PUSH_MESSAGE_H_
-#define _ABSTRACT_LAYER_PUSH_MESSAGE_H_
-
-#include <string>
-#include <dpl/shared_ptr.h>
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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_PUSH_MESSAGE_H__
+#define __TIZEN_PUSH_MESSAGE_H__
+
+#include <MultiCallbackUserData.h>
+
+#include "PushTypes.h"
+
+using namespace DeviceAPI::Common;
 
 namespace DeviceAPI {
 namespace Push {
 
-#define UNDEFINED_DATE -1
-
 class PushMessage
 {
-    std::string m_appData;
-    std::string m_alertMessage;
-    long long int m_date;
-
-  public:
+public:
     PushMessage();
-    PushMessage(std::string appData, std::string alertMessage, long long int date);
     virtual ~PushMessage();
 
     std::string getAppData() const;
-    void setAppData(std::string value);
+    void setAppData(std::string appData);
 
     std::string getAlertMessage() const;
-    void setAlertMessage(std::string value);
+    void setAlertMessage(std::string alertMessage);
 
-    long long int getDate() const;
-    void setDate(long long int value);
-};
+    time_t getDate() const;
+    void setDate(time_t date);
 
-typedef DPL::SharedPtr<PushMessage> PushMessagePtr;
-
-}
-}
+private:
+    std::string m_appData;
+    std::string m_alertMessage;
+    time_t m_date;
+};
 
-#endif /* _ABSTRACT_LAYER_PUSH_MESSAGE_H_ */
+} // Push
+} // DeviceAPI
 
+#endif // __TIZEN_PUSH_MESSAGE_H__
\ No newline at end of file
diff --git a/src/Push/PushResponseDispatcher.cpp b/src/Push/PushResponseDispatcher.cpp
deleted file mode 100644 (file)
index d43f26f..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * 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 <dpl/log/log.h>
-#include <CommonsJavaScript/JSCallbackManager.h>
-#include <JSTizenException.h>
-#include <JSTizenExceptionFactory.h>
-
-#include "PushResponseDispatcher.h"
-#include "PushConverter.h"
-#include "PushAsyncCallbackManager.h"
-#include "JSPushMessage.h"
-
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace DeviceAPI {
-namespace Push {
-
-PushResponseDispatcher& PushResponseDispatcher::getInstance()
-{
-    static PushResponseDispatcher instance;
-    return instance;
-}
-
-PushResponseDispatcher::PushResponseDispatcher() :
-    PushEventAnswerReceiverRegisterService(ThreadEnum::NULL_THREAD),
-    PushEventAnswerReceiverUnregisterService(ThreadEnum::NULL_THREAD),
-    PushEventAnswerReceiverConnectService(ThreadEnum::NULL_THREAD),
-    OnPushNotifiedListener(ThreadEnum::NULL_THREAD)
-{
-}
-
-PushResponseDispatcher::~PushResponseDispatcher()
-{
-}
-
-void PushResponseDispatcher::OnAnswerReceived(const IEventRegisterServicePtr &event)
-{
-    LogDebug("entered");
-    JSCallbackManagerPtr cbm = DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-    if (!cbm) {
-        LogError("Noo callback manager!");
-        return;
-    }
-
-       PushAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm);
-
-    Try
-    {
-        if (event->getResult()) {
-            PushConverter converter(cbm->getContext());
-            cbm->callOnSuccess(converter.toJSValueRef(event->getRegistrationId()));
-            return;
-        } else {
-            LogWarning("Registering failed.");
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("Error during processing answer.");
-    }
-    JSValueRef errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject(
-            cbm->getContext(), DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR);
-    cbm->callOnError(errorObject);
-}
-
-void PushResponseDispatcher::OnAnswerReceived(const IEventUnregisterServicePtr &event)
-{
-    LogDebug("entered");
-    JSCallbackManagerPtr cbm = DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-    if (!cbm) {
-        LogError("Noo callback manager!");
-        return;
-    }
-
-       PushAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm);
-
-    Try
-    {
-        if (event->getResult()) {
-            cbm->callOnSuccess();
-            return;
-        } else {
-            LogWarning("Unregistering failed.");
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("Error during processing answer.");
-    }
-    JSValueRef errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject(
-            cbm->getContext(), DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR);
-    cbm->callOnError(errorObject);
-}
-
-void PushResponseDispatcher::OnAnswerReceived(const IEventConnectServicePtr &event)
-{
-    LogDebug("entered");
-    JSCallbackManagerPtr cbm = DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-    if (!cbm) {
-        LogError("Noo callback manager!");
-        return;
-    }
-
-       PushAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(cbm);
-
-    Try
-    {
-        if (event->getResult()) {
-            LogInfo("Connect request succeeded.");
-            return;
-        } else {
-            LogWarning("Connect request failed.");
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("Error during processing answer.");
-    }
-    JSValueRef errorObject = DeviceAPI::Common::JSTizenExceptionFactory::makeErrorObject(
-            cbm->getContext(), DeviceAPI::Common::JSTizenException::UNKNOWN_ERROR);
-    cbm->callOnError(errorObject);
-}
-
-void PushResponseDispatcher::onAnswerReceived(const OnPushNotifiedPtr& event)
-{
-    LogDebug("entered");
-    JSCallbackManagerPtr listener =
-        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-    if (!listener) {
-        LogError("No listener callback!");
-        return;
-    }
-
-    Try
-    {
-        if (event->getResult()) {
-            listener->callOnSuccess(JSPushMessage::createJSPushMessage(listener->getContext(), event->getPushMessage()));
-            return;
-        } else {
-            LogWarning("Notification CB failed!");
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("Error during processing answer.");
-    }
-}
-
-}
-}
diff --git a/src/Push/PushResponseDispatcher.h b/src/Push/PushResponseDispatcher.h
deleted file mode 100755 (executable)
index 17fee7a..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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 _PUSH_RESPONSE_DISPATCHER_H_
-#define _PUSH_RESPONSE_DISPATCHER_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <Commons/EventListener.h>
-
-#include "IEventRegisterService.h"
-#include "IEventUnregisterService.h"
-#include "IEventConnectService.h"
-#include "OnPushNotified.h"
-
-namespace DeviceAPI {
-namespace Push {
-
-typedef WrtDeviceApis::Commons::EventAnswerReceiver<IEventRegisterService>
-PushEventAnswerReceiverRegisterService;
-typedef WrtDeviceApis::Commons::EventAnswerReceiver<IEventUnregisterService>
-PushEventAnswerReceiverUnregisterService;
-typedef WrtDeviceApis::Commons::EventAnswerReceiver<IEventConnectService>
-PushEventAnswerReceiverConnectService;
-typedef WrtDeviceApis::Commons::EventListener<OnPushNotified>
-OnPushNotifiedListener;
-
-class PushResponseDispatcher :
-       public PushEventAnswerReceiverRegisterService,
-       public PushEventAnswerReceiverUnregisterService,
-       public PushEventAnswerReceiverConnectService,
-       public OnPushNotifiedListener
-{
-  public:
-    static PushResponseDispatcher& getInstance();
-
-  private:
-    PushResponseDispatcher();
-    virtual ~PushResponseDispatcher();
-
-  protected:
-    void OnAnswerReceived(const IEventRegisterServicePtr &event);
-    void OnAnswerReceived(const IEventUnregisterServicePtr &event);
-    void OnAnswerReceived(const IEventConnectServicePtr &event);
-    void onAnswerReceived(const OnPushNotifiedPtr& event);
-};
-
-}
-}
-
-#endif /* _PUSH_RESPONSE_DISPATCHER_H_ */
diff --git a/src/Push/PushTypes.h b/src/Push/PushTypes.h
new file mode 100644 (file)
index 0000000..2048323
--- /dev/null
@@ -0,0 +1,34 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 _PUSH_TYPES_H_
+#define _PUSH_TYPES_H_
+
+#include <string>
+#include <vector>
+#include <map>
+
+namespace DeviceAPI {
+namespace Push {
+
+// typedef PushRegistrationId
+typedef std::string PushRegistrationId;
+
+} // Push
+} // DeviceAPI
+
+#endif // _PUSH_TYPES_H_
old mode 100755 (executable)
new mode 100644 (file)
index 342003a..b40a0bd
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 <Commons/FunctionDefinition.h>
 #include <Commons/FunctionDeclaration.h>
 #include <Commons/Exception.h>
-#include <dpl/exception.h>
 #include <map>
 
 #include "plugin_config.h"
@@ -33,9 +33,7 @@ namespace DeviceAPI {
 namespace Push {
 
 static FunctionMapping createPushFunctions();
-
-static FunctionMapping PushFunctions =
-    createPushFunctions();
+static FunctionMapping PushFunctions = createPushFunctions();
 
 DEFINE_FUNCTION_GETTER(Push, PushFunctions);
 
@@ -65,60 +63,60 @@ static FunctionMapping createPushFunctions()
     // registerService
     AceFunction registerServiceFunc = ACE_CREATE_FUNCTION(
             FUNCTION_REGISTER_SERVICE,
-            PUSH_FUNCTION_API_REGISTER_SERVICE,
+            PUSH_MANAGER_API_REGISTER_SERVICE,
             PUSH_FEATURES,
             DEVICE_LIST_PUSH);
 
     pushMapping.insert(std::make_pair(
-                               PUSH_FUNCTION_API_REGISTER_SERVICE,
+                               PUSH_MANAGER_API_REGISTER_SERVICE,
                                registerServiceFunc));
 
     // unregisterService
     AceFunction unregisterServiceFunc = ACE_CREATE_FUNCTION(
             FUNCTION_UNREGISTER_SERVICE,
-            PUSH_FUNCTION_API_UNREGISTER_SERVICE,
+            PUSH_MANAGER_API_UNREGISTER_SERVICE,
             PUSH_FEATURES,
             DEVICE_LIST_PUSH);
 
     pushMapping.insert(std::make_pair(
-                               PUSH_FUNCTION_API_UNREGISTER_SERVICE,
+                               PUSH_MANAGER_API_UNREGISTER_SERVICE,
                                unregisterServiceFunc));
 
     // connectService
     AceFunction connectServiceFunc = ACE_CREATE_FUNCTION(
             FUNCTION_CONNECT_SERVICE,
-            PUSH_FUNCTION_API_CONNECT_SERVICE,
+            PUSH_MANAGER_API_CONNECT_SERVICE,
             PUSH_FEATURES,
             DEVICE_LIST_PUSH);
 
     pushMapping.insert(std::make_pair(
-                               PUSH_FUNCTION_API_CONNECT_SERVICE,
+                               PUSH_MANAGER_API_CONNECT_SERVICE,
                                connectServiceFunc));
 
     // disconnectService
     AceFunction disconnectServiceFunc = ACE_CREATE_FUNCTION(
             FUNCTION_DISCONNECT_SERVICE,
-            PUSH_FUNCTION_API_DISCONNECT_SERVICE,
+            PUSH_MANAGER_API_DISCONNECT_SERVICE,
             PUSH_FEATURES,
             DEVICE_LIST_PUSH);
 
     pushMapping.insert(std::make_pair(
-                               PUSH_FUNCTION_API_DISCONNECT_SERVICE,
+                               PUSH_MANAGER_API_DISCONNECT_SERVICE,
                                disconnectServiceFunc));
 
     // getRegistrationId
     AceFunction getRegistrationIdFunc = ACE_CREATE_FUNCTION(
             FUNCTION_GET_REGISTRATION_ID,
-            PUSH_FUNCTION_API_GET_REGISTRATION_ID,
+            PUSH_MANAGER_API_GET_REGISTRATION_ID,
             PUSH_FEATURES,
             DEVICE_LIST_PUSH);
 
     pushMapping.insert(std::make_pair(
-                               PUSH_FUNCTION_API_GET_REGISTRATION_ID,
+                               PUSH_MANAGER_API_GET_REGISTRATION_ID,
                                getRegistrationIdFunc));
 
     return pushMapping;
 }
 
-}
-}
+} // Push
+} // DeviceAPI
old mode 100755 (executable)
new mode 100644 (file)
index 0e8bdcf..21af37a
@@ -1,18 +1,19 @@
-/*
- * 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.
- */
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 _PUSH_PLUGIN_CONFIG_H_
 #include <string>
 #include <Commons/FunctionDeclaration.h>
 
+#include <Logger.h>
+
 namespace DeviceAPI {
 namespace Push {
 
-// Functions from push manager
-#define PUSH_FUNCTION_API_REGISTER_SERVICE "registerService"
-#define PUSH_FUNCTION_API_UNREGISTER_SERVICE "unregisterService"
-#define PUSH_FUNCTION_API_CONNECT_SERVICE "connectService"
-#define PUSH_FUNCTION_API_DISCONNECT_SERVICE "disconnectService"
-#define PUSH_FUNCTION_API_GET_REGISTRATION_ID "getRegistrationId"
+// attributes
+#define PUSH_MESSAGE_APP_DATA "appData"
+#define PUSH_MESSAGE_ALERT_MESSAGE "alertMessage"
+#define PUSH_MESSAGE_DATE "date"
+
+// functions
+#define PUSH_MANAGER_API_REGISTER_SERVICE "registerService"
+#define PUSH_MANAGER_API_UNREGISTER_SERVICE "unregisterService"
+#define PUSH_MANAGER_API_CONNECT_SERVICE "connectService"
+#define PUSH_MANAGER_API_DISCONNECT_SERVICE "disconnectService"
+#define PUSH_MANAGER_API_GET_REGISTRATION_ID "getRegistrationId"
 
 DECLARE_FUNCTION_GETTER(Push);
 
 #define PUSH_CHECK_ACCESS(functionName) \
-       aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >( \
-       getPushFunctionData, \
-       functionName)
+    aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >( \
+    getPushFunctionData, \
+    functionName)
 
 }
 }
index b753d94..551dc9e 100644 (file)
@@ -1,73 +1,71 @@
-/*
- * 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.
- */
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 <dpl/log/log.h>
-
 #include <Commons/plugin_initializer_def.h>
 #include <Commons/WrtAccess/WrtAccess.h>
-#include <Commons/Exception.h>
+
+#include <GlobalContextManager.h>
 
 #include "JSPushManager.h"
-#include "PushListenerManager.h"
 
-namespace DeviceAPI {
-namespace Push {
+#include <Logger.h>
 
 using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 using namespace DeviceAPI::Common;
 
+namespace DeviceAPI {
+namespace Push {
+
 void on_widget_start_callback(int widgetId)
 {
-    LogDebug("[Tizen\\Push] on_widget_start_callback (" << widgetId << ")");
-
-       Try {
+    LogDebug("[Tizen\\Push] on_widget_start_callback (%d)", widgetId);
+    try {
         WrtAccessSingleton::Instance().initialize(widgetId);
-       } Catch (Exception) {
-               LogError("WrtAccess initialization failed");
-       }
+    } catch (...) {
+        LogError("WrtAccess initialization failed");
+    }
 }
 
 void on_widget_stop_callback(int widgetId)
 {
-    LogDebug("[Tizen\\Push] on_widget_stop_callback (" << widgetId << ")");
-
-       Try {
+    LogDebug("[Tizen\\Push] on_widget_stop_callback (%d)", widgetId);
+    try {
         WrtAccessSingleton::Instance().deinitialize(widgetId);
-       } Catch (Exception) {
-               LogError("WrtAccess deinitialization failed");
-       }
+    } catch (...) {
+        LogError("WrtAccess deinitialization failed");
+    }
 }
 
 void on_frame_load_callback(const void * context)
 {
-    LogDebug("[Tizen\\Push] on_frame_load_callback (" << context << ")");
+    LogDebug("[Tizen\\Push] on_frame_load_callback (%p)", context);
+    GlobalContextManager::getInstance()->addGlobalContext(static_cast<JSContextRef>(context));
 }
 
 void on_frame_unload_callback(const void * context)
 {
-    LogDebug("[Tizen\\Push] on_frame_unload_callback (" << context << ")");
-
-       PushListenerManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
+    LogDebug("[Tizen\\Push] on_frame_unload_callback (%p)", context);
+    GlobalContextManager::getInstance()->removeGlobalContext(static_cast<JSContextRef>(context));
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
-
 PLUGIN_ON_FRAME_LOAD(on_frame_load_callback)
 PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback)
 
@@ -78,6 +76,5 @@ PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
         NULL)
 PLUGIN_CLASS_MAP_END
 
-}
-}
-
+} // Push
+} // DeviceAPI
index 1a6219a..d89902c 100644 (file)
@@ -12,7 +12,6 @@ INCLUDE_DIRECTORIES(
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${filesystem_dest}
 )
 
index 74992bd..0913758 100755 (executable)
@@ -159,7 +159,7 @@ JSValueRef JSSystemSetting::setProperty(JSContextRef context, JSObjectRef object
        }
        if (argumentCount < 3) {
                LogDebug("Argument is too few");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
        }
        if (!check.isCallback(arguments[2])) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
@@ -253,7 +253,7 @@ JSValueRef JSSystemSetting::getProperty(JSContextRef context, JSObjectRef object
 
        if (argumentCount < 2) {
                LogDebug("Argument is too few");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
        }
        if (!check.isCallback(arguments[1])) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
index 135f6fd..894f173 100755 (executable)
@@ -55,6 +55,11 @@ EventWatchSysteminfo::EventWatchSysteminfo() :
 
 EventWatchSysteminfo::~EventWatchSysteminfo()
 {
+    if(m_lastValue)
+    {
+        JSCallbackManagerPtr m_cbm = DPL::StaticPointerCast< JSCallbackManager >(getPrivateData());
+        JSValueUnprotect(m_cbm->getContext(), m_lastValue);
+    }
     LogDebug("destroy event data, id=" << m_id);
     removeTimer();
 }
@@ -140,6 +145,9 @@ void EventWatchSysteminfo::processGetValue()
         m_lastValue = m_BaseProperty->getValue(context, (void*)((Systeminfo*)m_Systeminfo)->getConnectionHandle());
         return;
     }
+    else {
+        JSValueUnprotect(context, m_lastValue);
+    }
 
     JSValueRef* exception = NULL;
     if (m_BaseProperty->getWatchType() == WATCH_TYPE_CPU) {
@@ -412,6 +420,8 @@ void EventWatchSysteminfo::processGetValue()
         }
         m_lastValue = tmpValue;
     }
+
+    JSValueProtect(context, m_lastValue);
 }
 
 void EventWatchSysteminfo::setTimer()
index 9d080ec..e24374b 100755 (executable)
@@ -23,7 +23,8 @@ namespace Systeminfo {
 
 ISysteminfoPtr SysteminfoFactory::getSysteminfos()
 {
-    return ISysteminfoPtr(new Systeminfo());
+    static ISysteminfoPtr obj(new Systeminfo());
+    return obj;
 }
 
 SysteminfoFactory& SysteminfoFactory::getInstance()
diff --git a/src/Tizen/AnyFactory.cpp b/src/Tizen/AnyFactory.cpp
new file mode 100644 (file)
index 0000000..13a0f06
--- /dev/null
@@ -0,0 +1,253 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/*
+ * @file        AnyType.cpp
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief       Declaration of the JSFilter class
+ */
+
+#include "AnyFactory.h"
+
+#include <dpl/log/log.h>
+#include <string.h>
+#include <locale.h>
+#include <Commons/Exception.h>
+#include <PlatformException.h>
+#include <JSUtil.h>
+#include <sstream>
+
+namespace DeviceAPI {
+namespace Tizen {
+
+using namespace DeviceAPI::Common;
+
+class PrivateAny : public Any
+{
+public:
+       PrivateAny();
+       PrivateAny(JSContextRef context, const JSValueRef value, PrimitiveType type);
+       virtual ~PrivateAny();
+
+private:
+       bool isDate(JSContextRef jsContext, JSValueRef jsValue) const;
+       std::tm *toDateTm(time_t time) const;
+       std::string toJSON(JSContextRef jsContext, JSValueRef jsValue) const;
+       std::string toString(JSContextRef jsContext, JSValueRef jsValue) const;
+};
+
+PrivateAny::PrivateAny() : Any()
+{
+       m_isNullOrUndefined = true;
+       m_type = PrimitiveType_Null;
+       m_json = "null";
+       m_str = "null";
+}
+
+PrivateAny::PrivateAny(JSContextRef context, const JSValueRef value, PrimitiveType type) : Any()
+{
+       m_type = type;
+
+       if(type == PrimitiveType_NoType)
+               throw UnknownException("Cannot create any with NoType");
+
+       if(JSValueIsUndefined(context, value) || JSValueIsNull(context, value))
+               m_isNullOrUndefined = true;
+
+       try
+       {
+               if(type == PrimitiveType_Boolean)
+                       m_value.b = JSUtil::JSValueToBoolean(context, value);
+               else if(type == PrimitiveType_Long)
+                       m_value.l = JSUtil::JSValueToLong(context, value);
+               else if(type == PrimitiveType_ULong)
+                       m_value.ul = JSUtil::JSValueToULong(context, value);
+               else if(type == PrimitiveType_LongLong)
+                       m_value.ll = JSUtil::JSValueToLongLong(context, value);
+               else if(type == PrimitiveType_ULongLong)
+                       m_value.ull = JSUtil::JSValueToULongLong(context, value);
+               else if(type == PrimitiveType_Double)
+                       m_value.d = JSUtil::JSValueToDouble(context, value);
+               else if(type == PrimitiveType_String)
+               {
+                       m_value.str = new std::string();
+                       *m_value.str = JSUtil::JSValueToString(context, value);
+               }
+               else if(type == PrimitiveType_Time)
+                       m_value.t = toDateTm(JSUtil::JSValueToTimeT(context, value));
+       }
+       catch(BasePlatformException &e)
+       {
+               if(!m_isNullOrUndefined)
+               {
+                       throw e;
+               }
+
+               m_type = PrimitiveType_Null;
+               m_json = "null";
+       }
+
+       if(m_json.empty())
+               m_json = toJSON(context, value);
+
+       m_str = toString(context, value);
+}
+
+PrivateAny::~PrivateAny()
+{
+       if(m_type == PrimitiveType_String)
+       {
+               if(m_value.str != NULL)
+                       delete m_value.str;
+       }
+       else if(m_type == PrimitiveType_Time)
+       {
+               if(m_value.t != NULL)
+                       delete m_value.t;
+       }
+}
+
+bool PrivateAny::isDate(JSContextRef jsContext, JSValueRef jsValue) const
+{
+       JSObjectRef jsObjectGlobal = JSContextGetGlobalObject(jsContext);
+       JSStringRef jsStringDate = JSStringCreateWithUTF8CString("Date");
+       JSValueRef jsValueDate = JSObjectGetProperty(jsContext, jsObjectGlobal, jsStringDate, NULL);
+       JSStringRelease(jsStringDate);
+
+       JSObjectRef jsObjectDate = JSValueToObject(jsContext, jsValueDate, NULL);
+
+       return JSValueIsInstanceOfConstructor(jsContext, jsValue, jsObjectDate, NULL);
+}
+
+std::tm * PrivateAny::toDateTm(time_t time) const
+{
+       char* currentLocale = setlocale(LC_TIME, NULL);
+       if (currentLocale == NULL)
+               throw UnknownException("Fail to get current locale");
+       char* currentLocaleDup = strdup(currentLocale);
+       if (currentLocaleDup == NULL)
+               throw UnknownException("Fail to dup current locale");
+       if (setlocale(LC_TIME, "C") == NULL)
+               throw UnknownException("Fail to set locale");
+
+       std::tm *timeTm = new std::tm;
+       memcpy(timeTm, localtime(&time), sizeof(std::tm));
+
+       if (setlocale(LC_TIME, currentLocaleDup) == NULL)
+               throw UnknownException("Fail to set locale");
+
+       free(currentLocaleDup);
+
+       return timeTm;
+}
+
+std::string PrivateAny::toJSON(JSContextRef context, JSValueRef value) const
+{
+       JSValueRef jsError = NULL;
+       JSStringRef jsStrJson = JSValueCreateJSONString(context, value, 0, &jsError);
+       if(jsError != NULL || jsStrJson == NULL)
+       {
+               LogError("Fail to create JSON string");
+               return std::string("");
+       }
+
+       std::string result = JSUtil::JSStringToString(context, jsStrJson);
+       JSStringRelease(jsStrJson);
+
+       return result;
+}
+
+std::string PrivateAny::toString(JSContextRef context, JSValueRef value) const
+{
+       std::string result;
+
+       if(m_type == PrimitiveType_String)
+       {
+               result = *m_value.str;
+       }
+       else if(m_type == PrimitiveType_Long ||
+                       m_type == PrimitiveType_ULong ||
+                       m_type == PrimitiveType_LongLong ||
+                       m_type == PrimitiveType_ULongLong)
+       {
+               std::stringstream ss;
+
+               if(m_type == PrimitiveType_Long)
+                       ss << m_value.l;
+               else if(m_type == PrimitiveType_ULong)
+                       ss << m_value.ul;
+               else if(m_type == PrimitiveType_LongLong)
+                       ss << m_value.ll;
+               else if(m_type == PrimitiveType_ULongLong)
+                       ss << m_value.ull;
+
+               result = ss.str();
+       }
+       else
+       {
+               JSValueRef jsError = NULL;
+               JSStringRef jsStrJson = JSValueToStringCopy(context, value, &jsError);
+               if(jsError == NULL && jsStrJson != NULL)
+               {
+                       result = JSUtil::JSStringToString(context, jsStrJson);
+                       JSStringRelease(jsStrJson);
+               }
+       }
+
+       return result;
+}
+
+AnyPtr AnyFactory::createAny(JSContextRef context, JSValueRef value, PrimitiveType type)
+{
+       try
+       {
+               return AnyPtr(new PrivateAny(context, value, type));
+       }
+       catch(TypeMismatchException &e)
+       {
+               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Type error occured while converting JSValueRef");
+       }
+       catch(BasePlatformException &e)
+       {
+               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Unknown error occured while converting JSValueRef");
+       }
+
+       return AnyPtr(new PrivateAny());
+}
+
+AnyPtr AnyFactory::createAnyNoException(JSContextRef context, JSValueRef value, PrimitiveType type)
+{
+       try
+       {
+               return AnyPtr(new PrivateAny(context, value, type));
+       }
+       catch(BasePlatformException &e)
+       {
+               LogError("Error while converting (" << e.getName() << ") : " << e.getMessage());
+       }
+
+       return AnyPtr(new PrivateAny());
+}
+
+AnyPtr AnyFactory::createAnyEmpty(JSContextRef context)
+{
+       return AnyPtr(new PrivateAny());
+}
+
+} // Tizen
+} // DeviceAPI
diff --git a/src/Tizen/AnyFactory.h b/src/Tizen/AnyFactory.h
new file mode 100644 (file)
index 0000000..98d2c52
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/*
+ * @file        AnyFactory.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief       Declaration of the AnyFactory method
+ */
+
+#ifndef _API_ANY_FACTORY_H_
+#define _API_ANY_FACTORY_H_
+
+#include <ctime>
+#include <iomanip>
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <JavaScriptCore/JavaScript.h>
+#include "AnyType.h"
+
+namespace DeviceAPI {
+namespace Tizen {
+
+class AnyFactory {
+public:
+       static AnyPtr createAny(JSContextRef context, JSValueRef value, PrimitiveType type);
+       static AnyPtr createAnyNoException(JSContextRef context, JSValueRef value, PrimitiveType type);
+       static AnyPtr createAnyEmpty(JSContextRef context);
+};
+
+} // Tizen
+} // DeviceAPI
+
+#endif // _API_ANYTYPE_H_
index 430fa4d..1d770a2 100644 (file)
  * @brief       Declaration of the JSFilter class
  */
 
-#include <limits>
-#include <sstream>
-#include <Commons/Exception.h>
-#include <CommonsJavaScript/ScopedJSStringRef.h>
-#include <TimeUtilConverter.h>
-#include <JSTZDate.h>
 #include "AnyType.h"
 
-namespace DeviceAPI {\rnamespace Tizen {
+#include <string.h>
+#include <locale.h>
+#include <JSUtil.h>
 
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
+namespace DeviceAPI {
+namespace Tizen {
 
+using namespace DeviceAPI::Common;
 
-Any::Any()
+Any::Any() :
+               m_isNullOrUndefined(false),
+               m_priv(NULL),
+               m_ownership(false),
+               m_type(PrimitiveType_NoType)
 {
-       m_type = PrimitiveType_Null;
-       m_value.i = 0;
-       m_json = "null";
-       m_priv = NULL;
-}
-
-Any::Any(bool value)
-{
-       m_type = PrimitiveType_Boolean;
-       m_value.b = value;
-       m_json = value?"true":"false";
-       m_priv = NULL;
-}
-
-Any::Any(double value, std::string json)
-{
-       m_type = PrimitiveType_Double;
-       m_value.d = value;
-       m_json = json;
-       m_priv = NULL;
-
-       if(value == (double)((char)value))
-               m_type |= PrimitiveType_Char;
-       if(value == (double)((unsigned char)value))
-               m_type |= PrimitiveType_UChar;
-       if(value == (double)((int)value))
-               m_type |= PrimitiveType_Int;
-       if(value == (double)((unsigned int)value))
-               m_type |= PrimitiveType_UInt;
-       if(value == (double)((long)value))
-               m_type |= PrimitiveType_Long;
-       if(value == (double)((unsigned long)value))
-               m_type |= PrimitiveType_ULong;
-}
-
-Any::Any(std::string value)
-{
-       m_type = PrimitiveType_String;
-       m_value.s = new std::string(value);
-       m_json = "\"" + value + "\"";
-       m_priv = NULL;
-}
-
-Any::Any(std::tm value, std::string json)
-{
-       m_type = PrimitiveType_Time;
-       m_value.t = value;
-       m_json = json;
-       m_priv = NULL;
-}
-
-Any::Any(void * priv, std::string json)
-{
-       m_type = PrimitiveType_Object;
-       m_value.i = 0;
-       m_json = json;
-       m_priv = priv;
 }
 
 Any::~Any()
 {
-       if(m_type == PrimitiveType_String)
-               delete m_value.s;
-}
-
-std::string Any::toString() const
-{
-       std::stringstream oss;
-
-       if(m_type == PrimitiveType_Undefined || m_type == PrimitiveType_Null)
-               return "";
-       else if(m_type == PrimitiveType_Boolean)
-               return m_json;
-       else if(m_type == PrimitiveType_String)
-               return *m_value.s;
-       else if(m_type == PrimitiveType_Object)
-               return m_json;
-       else if(m_type & PrimitiveType_Number)
+       if(m_priv && m_ownership)
        {
-               if(m_type & PrimitiveType_ULong)
-                       oss << (unsigned long)m_value.d;
-               else if(m_type & PrimitiveType_Long)
-                       oss << (long)m_value.d;
-               else
-               {
-                       oss << std::setprecision(std::numeric_limits<double>::digits10);
-                       oss << std::setiosflags(std::ios::fixed);
-                       oss << m_value.d;
-               }
-
-               return oss.str();
+               delete m_priv;
        }
-       else if(m_type == PrimitiveType_Time)
-       {
-               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(4) << (m_value.t.tm_year + 1900);
-               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << (m_value.t.tm_mon + 1);
-               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << m_value.t.tm_mday;
-               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << m_value.t.tm_hour;
-               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << m_value.t.tm_min;
-               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << m_value.t.tm_sec;
-
-               return oss.str();
-       }
-       else
-               return m_json;
-}
-
-std::string Any::toJSON() const
-{
-       return m_json;
 }
 
-unsigned int Any::getType() const
+PrimitiveType Any::getType() const
 {
        return m_type;
 }
 
 bool Any::isType(PrimitiveType type) const
 {
-       return (bool)(m_type & type);
+       return (type == m_type);
 }
 
 bool Any::isNullOrUndefined() const
 {
-       return (bool)((m_type & PrimitiveType_Undefined) | (m_type & PrimitiveType_Null));
-}
-
-bool Any::getBool() const
-{
-       if(m_type != PrimitiveType_Boolean)
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
-
-       return m_value.b;
+       return m_isNullOrUndefined;
 }
 
-char Any::getChar() const
+std::string Any::toString() const
 {
-       if(!(m_type & PrimitiveType_Char))
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
-
-       return (char)m_value.d;
+       return m_str;
 }
 
-unsigned char Any::getUChar() const
+bool Any::getBool() const
 {
-       if(!(m_type & PrimitiveType_UChar))
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       if(m_type != PrimitiveType_Boolean)
+               return false;
 
-       return (unsigned char)m_value.d;
+       return m_value.b;
 }
 
-int Any::getInt() const
+long Any::getLong() const
 {
-       if(!(m_type & PrimitiveType_Int))
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       if(m_type != PrimitiveType_Long)
+               return static_cast<long>(0);
 
-       return (int)m_value.d;
+       return m_value.l;
 }
 
-unsigned int Any::getUInt() const
+unsigned long Any::getULong() const
 {
-       if(!(m_type & PrimitiveType_UInt))
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       if(m_type != PrimitiveType_ULong)
+               return static_cast<unsigned long>(0);
 
-       return (unsigned int)m_value.d;
+       return m_value.ul;
 }
 
-long Any::getLong() const
+long long Any::getLongLong() const
 {
-       if(!(m_type & PrimitiveType_Long))
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       if(m_type != PrimitiveType_LongLong)
+               return static_cast<long long>(0);
 
-       return (long)m_value.d;
+       return m_value.ll;
 }
 
-unsigned long Any::getULong() const
+unsigned long long Any::getULongLong() const
 {
-       if(!(m_type & PrimitiveType_ULong))
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       if(m_type != PrimitiveType_ULongLong)
+               return static_cast<unsigned long long>(0);
 
-       return (unsigned long)m_value.d;
+       return m_value.ull;
 }
 
 double Any::getDouble() const
 {
-       if(!(m_type & PrimitiveType_Double))
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       if(m_type != PrimitiveType_Double)
+               return static_cast<double>(0.0);
 
        return m_value.d;
 }
 
 std::string Any::getString() const
 {
-       if(m_type != PrimitiveType_String)
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       if(m_type != PrimitiveType_String || m_value.str == NULL)
+               return std::string("");
 
-       return *m_value.s;
+       return *m_value.str;
 }
 
-std::tm Any::getDateTm() const
+std::tm *Any::getDateTm() const
 {
-       if(m_type != PrimitiveType_Time)
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       if(m_type != PrimitiveType_Time || m_value.t == NULL)
+               return NULL;
 
        return m_value.t;
 }
 
 std::time_t Any::getTimeT() const
 {
-       if(m_type != PrimitiveType_Time)
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
-
-       std::tm *time = const_cast<std::tm*>(&(m_value.t));
-       return timegm(time);
-}
-
-AnyTypeConverter::AnyTypeConverter(JSContextRef context) :
-               Converter(context)
-{
-}
-
-AnyTypeConverter::~AnyTypeConverter()
-{
-}
-
-JSValueRef AnyTypeConverter::toJSValueRef(const AnyPtr& arg)
-{
-       if(arg->isType(PrimitiveType_Undefined))
-               return JSValueMakeUndefined(m_context);
-       else if(arg->isType(PrimitiveType_Null))
-               return JSValueMakeNull(m_context);
-       else if(arg->isType(PrimitiveType_Boolean))
-               return toJSValueRef(arg->getBool());
-       else if(arg->isType(PrimitiveType_Number))
-               return toJSValueRef(arg->getDouble());
-       else if(arg->isType(PrimitiveType_String))
-               return toJSValueRef(arg->getString());
-       else if(arg->isType(PrimitiveType_Time))
-               return toJSValueRef(arg->getDateTm());
-       else if(arg->isType(PrimitiveType_Object))
-       {
-               ScopedJSStringRef json(JSStringCreateWithUTF8CString(arg->toJSON().c_str()));
-               return JSValueMakeFromJSONString(m_context, json.get());
-       }
-
-       return JSValueMakeUndefined(m_context);
-}
-
-AnyPtr AnyTypeConverter::toAny(const JSValueRef &value)
-{
-       JSType jstype = JSValueGetType(m_context, value);
-       ScopedJSStringRef json(JSValueCreateJSONString(m_context, value, 0, NULL));
-
-       if(jstype == kJSTypeBoolean)
-               return AnyPtr(new Any(Converter::toBool(value)));
-       else if(jstype == kJSTypeNumber)
-               return AnyPtr(new Any(Converter::toDouble(value), toString(json.get())));
-       else if(jstype == kJSTypeString)
-               return AnyPtr(new Any(Converter::toString(value)));
-       else if(jstype == kJSTypeObject)
-       {
-               if(isDate(value))
-                       return AnyPtr(new Any(Converter::toDateTm(value), toString(json.get())));
-               else if(JSValueIsObjectOfClass(m_context, value, DeviceAPI::Time::JSTZDate::getClassRef()))
-               {
-                       DeviceAPI::Time::TimeUtilConverter timeConverter(m_context);
-                       std::tm tmValue = timeConverter.toTZDateTime(value);
-                       std::stringstream ss;
-                       ss<<timegm(&tmValue);
-                       return AnyPtr(new Any(tmValue, ss.str()));
-               }
-               else
-               {
-                       void *priv = NULL;
-                       JSObjectRef object = JSValueToObject(m_context, value, NULL);
-                       if (object)
-                               priv = JSObjectGetPrivate(object);
-
-                       return AnyPtr(new Any(priv, toString(json.get())));
-               }
-       }
-       else
-               return AnyPtr(new Any());
-}
-
-bool AnyTypeConverter::toBool(const AnyPtr& arg)
-{
-       return arg->getBool();
-}
-
-char AnyTypeConverter::toChar(const AnyPtr& arg)
-{
-       return arg->getChar();
-}
-
-unsigned char AnyTypeConverter::toUChar(const AnyPtr& arg)
-{
-       return arg->getUChar();
-}
-
-int AnyTypeConverter::toInt(const AnyPtr& arg)
-{
-       return arg->getInt();
-}
-
-unsigned int AnyTypeConverter::toUInt(const AnyPtr& arg)
-{
-       return arg->getUInt();
-}
-
-long AnyTypeConverter::toLong(const AnyPtr& arg)
-{
-       return arg->getLong();
-}
+       if(m_type != PrimitiveType_Time || m_value.t == NULL)
+               return static_cast<std::time_t>(0);
 
-unsigned long AnyTypeConverter::toULong(const AnyPtr& arg)
-{
-       return arg->getULong();
+       return mktime(m_value.t);
 }
 
-double AnyTypeConverter::toDouble(const AnyPtr& arg)
+std::string Any::getJSON() const
 {
-       return arg->getDouble();
-}
-
-std::string AnyTypeConverter::toString(const AnyPtr& arg)
-{
-       return arg->getString();
-}
-
-tm AnyTypeConverter::toDateTm(const AnyPtr& arg)
-{
-       return arg->getDateTm();
+       return m_json;
 }
 
-time_t AnyTypeConverter::toTimeT(const AnyPtr& arg)
+void * Any::getPriv() const
 {
-       return arg->getTimeT();
+       return m_priv;
 }
 
-bool AnyTypeConverter::isDate(const JSValueRef& arg)
+void Any::setPriv(void * priv, bool ownership)
 {
-       // this method originated from DeviceAPI::Common::Validator::isDate()
-       if ( JSValueIsNull( m_context, arg ) || JSValueIsUndefined( m_context, arg ) || !JSValueIsObject( m_context, arg ) )
-               return false;
+       if(m_priv && m_ownership)
+               delete m_priv;
 
-       Try {
-               toDateTm( arg );
-       } Catch(Exception) {
-               return false;
-       }
-       return true;
+       m_priv = priv;
+       m_ownership = ownership;
 }
 
 } // Tizen
index 5d50f4c..11ed696 100644 (file)
  * @file        AnyType.h
  * @author      Kisub Song (kisubs.song@samsung.com)
  * @version     0.1
- * @brief       Declaration of the JSFilter class
+ * @brief       Declaration of the Any class
  */
 
 #ifndef _API_ANYTYPE_H_
 #define _API_ANYTYPE_H_
 
 #include <ctime>
-#include <iomanip>
 #include <string>
 #include <dpl/shared_ptr.h>
-#include <CommonsJavaScript/Converter.h>
 
-namespace DeviceAPI {\rnamespace Tizen {
+namespace DeviceAPI {
+namespace Tizen {
 
-
-#define _PT_UNDEFINED  (0)
-#define _PT_NULL               (1 << 0)
-#define _PT_BOOLEAN            (1 << 1)
-#define _PT_CHAR               (1 << 2)
-#define _PT_UCHAR              (1 << 3)
-#define _PT_INT                        (1 << 4)
-#define _PT_UINT               (1 << 5)
-#define _PT_LONG               (1 << 6)
-#define _PT_ULONG              (1 << 7)
-#define _PT_DOUBLE             (1 << 8)
-#define _PT_STRING             (1 << 9)
-#define _PT_TIME               (1 << 10)
-#define _PT_OBJECT             (1 << 11)
-
-enum PrimitiveType {
-       PrimitiveType_NoType    = 0,
-       PrimitiveType_Undefined = _PT_UNDEFINED,
-       PrimitiveType_Null              = _PT_NULL,
-       PrimitiveType_Boolean   = _PT_BOOLEAN,
-       PrimitiveType_Char              = _PT_CHAR,
-       PrimitiveType_UChar             = _PT_UCHAR,
-       PrimitiveType_Int               = _PT_INT,
-       PrimitiveType_UInt              = _PT_UINT,
-       PrimitiveType_Long              = _PT_LONG,
-       PrimitiveType_ULong             = _PT_ULONG,
-       PrimitiveType_Double    = _PT_DOUBLE,
-       PrimitiveType_String    = _PT_STRING,
-       PrimitiveType_Time              = _PT_TIME,
-       PrimitiveType_Object    = _PT_OBJECT,
-       PrimitiveType_Number    = (_PT_CHAR | _PT_UCHAR | _PT_INT | _PT_UINT |
-                                                               _PT_LONG | _PT_ULONG | _PT_DOUBLE),
-       PrimitiveType_Integer   = (_PT_CHAR | _PT_UCHAR | _PT_INT | _PT_UINT |
-                                                               _PT_LONG | _PT_ULONG),
-       PrimitiveType_Any               = (_PT_BOOLEAN | _PT_CHAR | _PT_UCHAR | _PT_INT |
-                                                               _PT_UINT | _PT_LONG | _PT_ULONG | _PT_DOUBLE |
-                                                               _PT_STRING | _PT_TIME | _PT_OBJECT)
-};
-
-class Any
+template<class T>
+class AnySharedPtrWrapper
 {
-private:
-       union AnyTypeUnion
+public:
+       typedef T PrivateClass;
+       typedef DPL::SharedPtr<PrivateClass> PrivSharedPtr;
+
+       AnySharedPtrWrapper(PrivSharedPtr &obj) : m_object(obj)
        {
-               bool b;
-               double d;
-               std::tm t;
-               std::string* s;
-               int i;
-       };
+       }
 
-       unsigned int m_type;
+       virtual ~AnySharedPtrWrapper()
+       {
+               m_object = PrivSharedPtr(NULL);
+       }
 
-       AnyTypeUnion m_value;
+       PrivSharedPtr getObject()
+       {
+               return m_object;
+       }
 
-       std::string m_json;
+private:
+       PrivSharedPtr m_object;
+};
 
-       void * m_priv;
+enum PrimitiveType {
+       PrimitiveType_NoType,
+       PrimitiveType_Null,
+       PrimitiveType_Boolean,
+       PrimitiveType_Long,
+       PrimitiveType_ULong,
+       PrimitiveType_LongLong,
+       PrimitiveType_ULongLong,
+       PrimitiveType_Double,
+       PrimitiveType_String,
+       PrimitiveType_Time,
+       PrimitiveType_Object,
+       PrimitiveType_PlatformObject
+};
 
+class Any
+{
 public:
        Any();
-       Any(bool value);
-       Any(double value, std::string json);
-       Any(std::string value);
-       Any(std::tm value, std::string json);
-       Any(void * priv, std::string json);
        virtual ~Any();
 
-       virtual std::string toString() const;
-       std::string toJSON() const;
-
-       unsigned int getType() const;
+       PrimitiveType getType() const;
        bool isType(PrimitiveType type) const;
        bool isNullOrUndefined() const;
 
+       std::string toString() const;
+
        bool getBool() const;
-       char getChar() const;
-       unsigned char getUChar() const;
-       int getInt() const;
-       unsigned int getUInt() const;
        long getLong() const;
        unsigned long getULong() const;
+       long long getLongLong() const;
+       unsigned long long getULongLong() const;
        double getDouble() const;
        std::string getString() const;
-       std::tm getDateTm() const;
+       std::tm *getDateTm() const;
        std::time_t getTimeT() const;
-};
-typedef DPL::SharedPtr<Any> AnyPtr;
 
-typedef std::vector<AnyPtr> AnyArray;
-typedef DPL::SharedPtr<AnyArray> AnyArrayPtr;
+       std::string getJSON() const;
 
-class AnyTypeConverter : public WrtDeviceApis::CommonsJavaScript::Converter
-{
-public:
-       explicit AnyTypeConverter(JSContextRef context);
-       virtual ~AnyTypeConverter();
-
-       JSValueRef toJSValueRef(const AnyPtr& arg);
-       AnyPtr toAny(const JSValueRef &value);
-
-       bool toBool(const AnyPtr& arg);
-       char toChar(const AnyPtr& arg);
-       unsigned char toUChar(const AnyPtr& arg);
-       int toInt(const AnyPtr& arg);
-       unsigned int toUInt(const AnyPtr& arg);
-       long toLong(const AnyPtr& arg);
-       unsigned long toULong(const AnyPtr& arg);
-       double toDouble(const AnyPtr& arg);
-       std::string toString(const AnyPtr& arg);
-       tm toDateTm(const AnyPtr& arg);
-       time_t toTimeT(const AnyPtr& arg);
-
-       using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef;
-       using WrtDeviceApis::CommonsJavaScript::Converter::toString;
-       using WrtDeviceApis::CommonsJavaScript::Converter::toDateTm;
+       void * getPriv() const;
+       void setPriv(void * priv, bool ownership);
 
 protected:
-       bool isDate(const JSValueRef& arg);
-};
+       union AnyTypeUnion
+       {
+               bool b;
+               long l;
+               unsigned long ul;
+               long long ll;
+               unsigned long long ull;
+               double d;
+               std::string* str;
+               std::tm *t;
+       };
+
+       AnyTypeUnion    m_value;
+       bool            m_isNullOrUndefined;
 
-typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<AnyTypeConverter> AnyTypeConverterFactory;
+       std::string     m_json;
+       std::string     m_str;
+
+       void *          m_priv;
+       bool            m_ownership;
+
+       PrimitiveType   m_type;
+};
+typedef DPL::SharedPtr<Any> AnyPtr;
 
 } // Tizen
 } // DeviceAPI
index 675071a..64db127 100644 (file)
@@ -7,18 +7,17 @@ PKG_CHECK_MODULES(platform_pkgs_tizen REQUIRED wrt-plugins-plugin-manager)
 
 INCLUDE_DIRECTORIES(
        ${TOP}/Common
-       ${TOP}/TimeUtil
        ${platform_pkgs_tizen_INCLUDE_DIRS}
 )
 
 SET(CMAKE_INSTALL_RPATH
        ${CMAKE_INSTALL_RPATH}
        ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
-       ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest}
 )
 
 SET(SRCS_IMPL
        AnyType.cpp
+       AnyFactory.cpp
        FilterFactory.cpp
        IFilter.cpp
        CompositeFilter.cpp
@@ -26,6 +25,7 @@ SET(SRCS_IMPL
        AttributeRangeFilter.cpp
        SortMode.cpp
        IFilterVisitor.cpp
+       IFilterProperties.cpp
        FilterValidator.cpp
        SimpleCoordinates.cpp
        JSAttributeFilter.cpp
@@ -46,7 +46,6 @@ TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME}
        ${LIBS_COMMON}
        ${LIBS_WIDGETDB}
        ${platform_pkgs_tizen_LIBRARIES}
-       ${timeutil_impl}
 )
 
 SET(SRCS_CONFIG
index 231d228..e7d24d9 100644 (file)
 #include "JSCompositeFilter.h"
 #include "JSSortMode.h"
 #include "FilterConverter.h"
+#include "AnyFactory.h"
 
-#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_TYPE                          "type"
-#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_ORDER                         "order"
-#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_FILTERS                       "filters"
-#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_IDS                           "ids"
-#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_ATTRIBUTE_NAME                "attributeName"
-#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_FLAG                    "matchFlag"
-#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_VALUES          "matchValues"
-#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_INITIAL_VALUE         "initialValue"
-#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_END_VALUE                     "endValue"
+#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_TYPE               "type"
+#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_ORDER              "order"
+#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_FILTERS            "filters"
+#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_IDS                "ids"
+#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_ATTRIBUTE_NAME     "attributeName"
+#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_FLAG         "matchFlag"
+#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_VALUE        "matchValue"
+#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_INITIAL_VALUE      "initialValue"
+#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_END_VALUE          "endValue"
 
-namespace DeviceAPI {\rnamespace Tizen {
+namespace DeviceAPI {
+namespace Tizen {
 
 using namespace DeviceAPI::Tizen;
 using namespace WrtDeviceApis::Commons;
@@ -50,9 +52,213 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 
 using namespace std;
 
-FilterConverter::FilterConverter(JSContextRef context) : Converter(context)
+BaseFilterConverter::BaseFilterConverter(JSContextRef context) : Converter(context)
 {
-       initFilterAttrs();
+       LogDebug("entered");
+}
+
+BaseFilterConverter::~BaseFilterConverter()
+{
+       LogDebug("entered");
+}
+
+JSValueRef BaseFilterConverter::toJSValueRef(const SortModePtr& arg)
+{
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "SortMode is NULL.");
+
+       return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSSortMode::getClassRef(), arg);
+}
+
+SortModePtr BaseFilterConverter::toSortMode(const JSValueRef& arg)
+{
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSSortMode::isObjectOfClass(m_context, arg))
+               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
+
+       return JSSortMode::getSortMode(m_context, arg);
+}
+
+JSValueRef BaseFilterConverter::toJSValueRef(const SortModeArrayPtr& arg)
+{
+       // Not used any more.
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "SortModeArray is NULL.");
+
+       int size = arg->size();
+
+       JSObjectRef resultObject = JSCreateArrayObject(m_context, 0, NULL);
+       if (!resultObject)
+               ThrowMsg(ConversionException, "Can not create array object.");
+
+       for(int i = 0; i < size; i++)
+       {
+               JSValueRef jsvalue = toJSValueRef(arg->at(i));
+               if (!JSSetArrayElement(m_context, resultObject, i, jsvalue))
+                       ThrowMsg(ConversionException, "Can not fill SortMode array.");
+       }
+
+       return static_cast<JSValueRef>(resultObject);
+}
+
+SortModeArrayPtr BaseFilterConverter::toSortModeArray(const JSValueRef& arg)
+{
+       // Not used any more.
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSIsArrayValue(m_context, arg))
+               ThrowMsg(InvalidArgumentException, "Not an array type.");
+
+       SortModeArrayPtr sortModeArray = SortModeArrayPtr(new SortModeArray());
+       JSObjectRef object = toJSObjectRef(arg);
+
+       unsigned int length = JSGetArrayLength(m_context, object);
+       for(unsigned int i=0; i<length; i++)
+       {
+               JSValueRef value = JSGetArrayElement(m_context, object, i);
+
+               if(JSValueIsNull(m_context, value) ||  JSValueIsUndefined(m_context, value)) {
+                       ThrowMsg(InvalidArgumentException, "CompositeFilter.filters has null elements.");
+               }
+
+               SortModePtr sortMode = toSortMode(value);
+
+               sortModeArray->push_back(sortMode);
+       }
+
+       return sortModeArray;
+}
+
+JSValueRef BaseFilterConverter::toJSValueRef(const FilterType& arg)
+{
+       string compositeFilterTypeStr;
+
+       if(arg == UNION_FILTER)
+               compositeFilterTypeStr = "UNION";
+       else if(arg == INTERSECTION_FILTER)
+               compositeFilterTypeStr = "INTERSECTION";
+       else
+               ThrowMsg(ConversionException, "Can not create CompositeFilterType.");
+
+       return toJSValueRef(compositeFilterTypeStr);
+}
+
+FilterType BaseFilterConverter::toCompositeFilterType(const JSValueRef& arg)
+{
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSValueIsString(m_context, arg))
+               ThrowMsg(InvalidArgumentException, "Value is not an string.");
+
+       string compositeFilterTypeStr = toString(arg);
+       FilterType compositeFilterType;
+
+       if(compositeFilterTypeStr == "UNION")
+               compositeFilterType = UNION_FILTER;
+       else if(compositeFilterTypeStr == "INTERSECTION")
+               compositeFilterType = INTERSECTION_FILTER;
+       else
+               ThrowMsg(InvalidArgumentException, "CompositeFilterType cannot have " << compositeFilterTypeStr);
+
+       return compositeFilterType;
+}
+
+JSValueRef BaseFilterConverter::toJSValueRef(const MatchFlag& arg)
+{
+       string matchFlagStr;
+
+       if(arg == MATCH_EXACTLY)
+               matchFlagStr = "EXACTLY";
+       else if(arg == MATCH_FULLSTRING)
+               matchFlagStr = "FULLSTRING";
+       else if(arg == MATCH_CONTAINS)
+               matchFlagStr = "CONTAINS";
+       else if(arg == MATCH_STARTSWITH)
+               matchFlagStr = "STARTSWITH";
+       else if(arg == MATCH_ENDSWITH)
+               matchFlagStr = "ENDSWITH";
+       else if(arg == MATCH_EXISTS)
+               matchFlagStr = "EXISTS";
+       else
+               ThrowMsg(ConversionException, "Can not create MatchFlag.");
+
+       return toJSValueRef(matchFlagStr);
+}
+
+MatchFlag BaseFilterConverter::toMatchFlag(const JSValueRef& arg)
+{
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSValueIsString(m_context, arg))
+               ThrowMsg(InvalidArgumentException, "Value is not an string.");
+
+       string matchFlagStr = toString(arg);
+       MatchFlag matchFlag;
+
+       if(matchFlagStr == "EXACTLY")
+               matchFlag = MATCH_EXACTLY;
+       else if(matchFlagStr == "FULLSTRING")
+               matchFlag = MATCH_FULLSTRING;
+       else if(matchFlagStr == "CONTAINS")
+               matchFlag = MATCH_CONTAINS;
+       else if(matchFlagStr == "STARTSWITH")
+               matchFlag = MATCH_STARTSWITH;
+       else if(matchFlagStr == "ENDSWITH")
+               matchFlag = MATCH_ENDSWITH;
+       else if(matchFlagStr == "EXISTS")
+               matchFlag = MATCH_EXISTS;
+       else
+               ThrowMsg(InvalidArgumentException, "FilterMatchFlag cannot have " << matchFlagStr);
+
+       return matchFlag;
+}
+
+JSValueRef BaseFilterConverter::toJSValueRef(const SortOrder& arg)
+{
+       string sortOrderStr;
+
+       if(arg == ASCENDING_SORT_ORDER)
+               sortOrderStr = "ASC";
+       else if(arg == DESCENDING_SORT_ORDER)
+               sortOrderStr = "DESC";
+       else
+               ThrowMsg(ConversionException, "Can not create SortModeOrder.");
+
+       return toJSValueRef(sortOrderStr);
+}
+
+SortOrder BaseFilterConverter::toSortOrder(const JSValueRef& arg)
+{
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSValueIsString(m_context, arg))
+               ThrowMsg(InvalidArgumentException, "Value is not an string.");
+
+       string sortOrderStr = toString(arg);
+       SortOrder sortOrder;
+
+       if(sortOrderStr == "ASC")
+               sortOrder = ASCENDING_SORT_ORDER;
+       else if(sortOrderStr == "DESC")
+               sortOrder = DESCENDING_SORT_ORDER;
+       else
+               ThrowMsg(InvalidArgumentException, "SortModeOrder cannot have " << sortOrderStr);
+
+       return sortOrder;
+}
+
+FilterConverter::FilterConverter(JSContextRef context, PropertyStructArray properties, bool exception) :
+               BaseFilterConverter(context),
+               IFilterProperties(properties),
+               m_exception(exception)
+{
+       LogDebug("entered");
 }
 
 FilterConverter::~FilterConverter()
@@ -99,13 +305,13 @@ FilterPtr FilterConverter::toFilter(const JSValueRef& arg)
                //ThrowMsg(InvalidArgumentException, "Filter is not object.");
 
        if(JSCompositeFilter::isObjectOfClass(m_context, arg))
-               return DPL::StaticPointerCast<IFilter>(JSCompositeFilter::getCompositeFilter(m_context, arg));
+               return DPL::StaticPointerCast<IFilter>(toCompositeFilter(arg));
 
        if(JSAttributeFilter::isObjectOfClass(m_context, arg))
-               return DPL::StaticPointerCast<IFilter>(JSAttributeFilter::getAttributeFilter(m_context, arg));
+               return DPL::StaticPointerCast<IFilter>(toAttributeFilter(arg));
 
        if(JSAttributeRangeFilter::isObjectOfClass(m_context, arg))
-               return DPL::StaticPointerCast<IFilter>(JSAttributeRangeFilter::getAttributeRangeFilter(m_context, arg));
+               return DPL::StaticPointerCast<IFilter>(toAttributeRangeFilter(arg));
 
        //ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
        return FilterPtr(NULL);
@@ -213,7 +419,7 @@ JSValueRef FilterConverter::toJSValueRef(const AttributeFilterPtr& arg)
        if(arg == NULL)
                ThrowMsg(NullPointerException, "AttributeFilter is NULL.");
 
-       return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSAttributeFilter::getClassRef(), arg);
+       return JSAttributeFilter::createJSObject(m_context, arg, JSValueMakeUndefined(m_context));
 }
 
 AttributeFilterPtr FilterConverter::toAttributeFilter(const JSValueRef& arg)
@@ -224,311 +430,117 @@ AttributeFilterPtr FilterConverter::toAttributeFilter(const JSValueRef& arg)
        if(!JSAttributeFilter::isObjectOfClass(m_context, arg))
                ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
 
-       return JSAttributeFilter::getAttributeFilter(m_context, arg);
-}
+       AttributeFilterPtr attributeFilter = JSAttributeFilter::getAttributeFilter(m_context, arg);
 
-JSValueRef FilterConverter::toJSValueRef(const AttributeRangeFilterPtr& arg)
-{
-       if(arg == NULL)
-               ThrowMsg(NullPointerException, "AttributeRangeFilter is NULL.");
+       const ScopedJSStringRef jsStrMatchValue(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_VALUE));
+       JSObjectRef argObj = JSValueToObject(m_context, arg, NULL);
 
-       return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSAttributeRangeFilter::getClassRef(), arg);
-}
+       JSValueRef jsValueMatchValue = JSObjectGetProperty(m_context, argObj, jsStrMatchValue.get(), NULL);
+       AnyPtr any = toAny(jsValueMatchValue, attributeFilter->getAttributeName());
 
-AttributeRangeFilterPtr FilterConverter::toAttributeRangeFilter(const JSValueRef& arg)
-{
-       if(arg == NULL)
-               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+       toAnyCustom(jsValueMatchValue, attributeFilter->getAttributeName(), any);
 
-       if(!JSAttributeRangeFilter::isObjectOfClass(m_context, arg))
-               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
+       attributeFilter->setMatchValue(any);
 
-       return JSAttributeRangeFilter::getAttributeRangeFilter(m_context, arg);
+       return attributeFilter;
 }
 
-JSValueRef FilterConverter::toJSValueRef(const SortModePtr& arg)
+JSValueRef FilterConverter::toJSValueRef(const AttributeRangeFilterPtr& arg)
 {
        if(arg == NULL)
-               ThrowMsg(NullPointerException, "SortMode is NULL.");
+               ThrowMsg(NullPointerException, "AttributeRangeFilter is NULL.");
 
-       return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSSortMode::getClassRef(), arg);
+       return JSAttributeRangeFilter::createJSObject(m_context, arg,
+                       JSValueMakeUndefined(m_context), JSValueMakeUndefined(m_context));
 }
 
-SortModePtr FilterConverter::toSortMode(const JSValueRef& arg)
+AttributeRangeFilterPtr FilterConverter::toAttributeRangeFilter(const JSValueRef& arg)
 {
        if(arg == NULL)
                ThrowMsg(NullPointerException, "JSValueRef is NULL.");
 
-       if(!JSSortMode::isObjectOfClass(m_context, arg))
+       if(!JSAttributeRangeFilter::isObjectOfClass(m_context, arg))
                ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
 
-       return JSSortMode::getSortMode(m_context, arg);
-}
-
-JSValueRef FilterConverter::toJSValueRef(const SortModeArrayPtr& arg)
-{
-       // Not used any more.
-       if(arg == NULL)
-               ThrowMsg(NullPointerException, "SortModeArray is NULL.");
-
-       int size = arg->size();
-
-       JSObjectRef resultObject = JSCreateArrayObject(m_context, 0, NULL);
-       if (!resultObject)
-               ThrowMsg(ConversionException, "Can not create array object.");
-
-       for(int i = 0; i < size; i++)
-       {
-               JSValueRef jsvalue = toJSValueRef(arg->at(i));
-               if (!JSSetArrayElement(m_context, resultObject, i, jsvalue))
-                       ThrowMsg(ConversionException, "Can not fill SortMode array.");
-       }
-
-       return static_cast<JSValueRef>(resultObject);
-}
-
-SortModeArrayPtr FilterConverter::toSortModeArray(const JSValueRef& arg)
-{
-       // Not used any more.
-       if(arg == NULL)
-               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
-
-       if(!JSIsArrayValue(m_context, arg))
-               ThrowMsg(InvalidArgumentException, "Not an array type.");
-
-       SortModeArrayPtr sortModeArray = SortModeArrayPtr(new SortModeArray());
-       JSObjectRef object = toJSObjectRef(arg);
-
-       unsigned int length = JSGetArrayLength(m_context, object);
-       for(unsigned int i=0; i<length; i++)
-       {
-               JSValueRef value = JSGetArrayElement(m_context, object, i);
-
-               if(JSValueIsNull(m_context, value) ||  JSValueIsUndefined(m_context, value)) {
-                       ThrowMsg(InvalidArgumentException, "CompositeFilter.filters has null elements.");
-               }
-
-               SortModePtr sortMode = toSortMode(value);
-
-               sortModeArray->push_back(sortMode);
-       }
-
-       return sortModeArray;
-}
-
-JSValueRef FilterConverter::toJSValueRef(const AnyPtr& arg)
-{
-       if(arg == NULL)
-               ThrowMsg(NullPointerException, "Any is NULL.");
-
-       AnyTypeConverterFactory::ConverterType converter =
-                       AnyTypeConverterFactory::getConverter(m_context);
-
-       return converter->toJSValueRef(arg);
-}
-
-AnyPtr FilterConverter::toAny(const JSValueRef& arg)
-{
-       if(arg == NULL)
-               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
-
-       AnyArrayPtr retVal;
-
-       AnyTypeConverterFactory::ConverterType converter =
-                       AnyTypeConverterFactory::getConverter(m_context);
+       AttributeRangeFilterPtr attributeRangeFilter = JSAttributeRangeFilter::getAttributeRangeFilter(m_context, arg);
 
-       return converter->toAny(arg);
-}
-
-JSValueRef FilterConverter::toJSValueRef(const AnyArrayPtr& arg)
-{
-       if(arg == NULL)
-               ThrowMsg(NullPointerException, "AnyArray is NULL.");
+       const ScopedJSStringRef jsStrInitialValue(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_INITIAL_VALUE));
+       const ScopedJSStringRef jsStrEndValue(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_END_VALUE));
 
-       AnyTypeConverterFactory::ConverterType converter =
-                       AnyTypeConverterFactory::getConverter(m_context);
+       JSObjectRef argObj = JSValueToObject(m_context, arg, NULL);
 
-       int size = arg->size();
+       JSValueRef jsValueInitialValue = JSObjectGetProperty(m_context, argObj, jsStrInitialValue.get(), NULL);
+       AnyPtr anyInit = toAny(jsValueInitialValue, attributeRangeFilter->getAttributeName());
+       toAnyCustom(jsValueInitialValue, attributeRangeFilter->getAttributeName(), anyInit);
+       attributeRangeFilter->setInitialValue(anyInit);
 
-       JSObjectRef resultObject = JSCreateArrayObject(m_context, 0, NULL);
-       if (!resultObject)
-               ThrowMsg(ConversionException, "Can not create array object.");
-
-       for(int i = 0; i < size; i++)
-       {
-               JSValueRef jsvalue = converter->toJSValueRef(arg->at(i));
-               if (!JSSetArrayElement(m_context, resultObject, i, jsvalue))
-                       ThrowMsg(ConversionException, "Can not fill any array.");
-       }
+       JSValueRef jsValueEndValue = JSObjectGetProperty(m_context, argObj, jsStrEndValue.get(), NULL);
+       AnyPtr anyEnd = toAny(jsValueEndValue, attributeRangeFilter->getAttributeName());
+       toAnyCustom(jsValueEndValue, attributeRangeFilter->getAttributeName(), anyEnd);
+       attributeRangeFilter->setEndValue(anyEnd);
 
-       return static_cast<JSValueRef>(resultObject);
+       return attributeRangeFilter;
 }
 
-AnyArrayPtr FilterConverter::toAnyArray(const JSValueRef& arg)
+JSValueRef FilterConverter::toJSValueRef(const AnyPtr &arg)
 {
-       if(arg == NULL)
-               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+       PrimitiveType type = arg->getType();
 
-       AnyArrayPtr retVal;
-
-       retVal = AnyArrayPtr(new AnyArray());
-
-       JSObjectRef obj = toJSObjectRef(arg);
-       AnyTypeConverterFactory::ConverterType converter =
-                       AnyTypeConverterFactory::getConverter(m_context);
-
-       unsigned int length = JSGetArrayLength(m_context, obj);
-       for(unsigned int i=0; i<length; i++)
+       switch(type)
        {
-               JSValueRef value = JSGetArrayElement(m_context, obj, i);
-
-               if(JSValueIsNull(m_context, value) ||  JSValueIsUndefined(m_context, value)) {
-                       ThrowMsg(InvalidArgumentException, "IDFilter.ids has null elements.");
-               }
-               AnyPtr any = converter->toAny(value);
-
-               retVal->push_back(any);
+       case PrimitiveType_NoType:
+       case PrimitiveType_Null:
+               return JSValueMakeNull(m_context);
+               break;
+       case PrimitiveType_Boolean:
+               return toJSValueRef(arg->getBool());
+               break;
+       case PrimitiveType_Long:
+               return toJSValueRef(arg->getLong());
+               break;
+       case PrimitiveType_ULong:
+               return toJSValueRef(arg->getULong());
+               break;
+       case PrimitiveType_LongLong:
+               return toJSValueRef(arg->getLongLong());
+               break;
+       case PrimitiveType_ULongLong:
+               return toJSValueRef(static_cast<double>(arg->getULong()));
+               break;
+       case PrimitiveType_Double:
+               return toJSValueRef(arg->getDouble());
+               break;
+       case PrimitiveType_String:
+               return toJSValueRef(arg->getString());
+               break;
+       case PrimitiveType_Time:
+               return toJSValueRef(*arg->getDateTm());
+               break;
+       case PrimitiveType_Object:
+       case PrimitiveType_PlatformObject:
+       default:
+               break;
        }
-
-       return retVal;
-}
-
-JSValueRef FilterConverter::toJSValueRef(const FilterType& arg)
-{
-       string compositeFilterTypeStr;
-
-       if(arg == UNION_FILTER)
-               compositeFilterTypeStr = "UNION";
-       else if(arg == INTERSECTION_FILTER)
-               compositeFilterTypeStr = "INTERSECTION";
-       else
-               ThrowMsg(ConversionException, "Can not create CompositeFilterType.");
-
-       return toJSValueRef(compositeFilterTypeStr);
-}
-
-FilterType FilterConverter::toCompositeFilterType(const JSValueRef& arg)
-{
-       if(arg == NULL)
-               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
-
-       if(!JSValueIsString(m_context, arg))
-               ThrowMsg(InvalidArgumentException, "Value is not an string.");
-
-       string compositeFilterTypeStr = toString(arg);
-       FilterType compositeFilterType;
-
-       if(compositeFilterTypeStr == "UNION")
-               compositeFilterType = UNION_FILTER;
-       else if(compositeFilterTypeStr == "INTERSECTION")
-               compositeFilterType = INTERSECTION_FILTER;
-       else
-               ThrowMsg(InvalidArgumentException, "CompositeFilterType cannot have " << compositeFilterTypeStr);
-
-       return compositeFilterType;
-}
-
-JSValueRef FilterConverter::toJSValueRef(const MatchFlag& arg)
-{
-       string matchFlagStr;
-
-       if(arg == MATCH_EXACTLY)
-               matchFlagStr = "EXACTLY";
-       else if(arg == MATCH_FULLSTRING)
-               matchFlagStr = "FULLSTRING";
-       else if(arg == MATCH_CONTAINS)
-               matchFlagStr = "CONTAINS";
-       else if(arg == MATCH_STARTSWITH)
-               matchFlagStr = "STARTSWITH";
-       else if(arg == MATCH_ENDSWITH)
-               matchFlagStr = "ENDSWITH";
-       else if(arg == MATCH_EXISTS)
-               matchFlagStr = "EXISTS";
-       else
-               ThrowMsg(ConversionException, "Can not create MatchFlag.");
-
-       return toJSValueRef(matchFlagStr);
-}
-
-MatchFlag FilterConverter::toMatchFlag(const JSValueRef& arg)
-{
-       if(arg == NULL)
-               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
-
-       if(!JSValueIsString(m_context, arg))
-               ThrowMsg(InvalidArgumentException, "Value is not an string.");
-
-       string matchFlagStr = toString(arg);
-       MatchFlag matchFlag;
-
-       if(matchFlagStr == "EXACTLY")
-               matchFlag = MATCH_EXACTLY;
-       else if(matchFlagStr == "FULLSTRING")
-               matchFlag = MATCH_FULLSTRING;
-       else if(matchFlagStr == "CONTAINS")
-               matchFlag = MATCH_CONTAINS;
-       else if(matchFlagStr == "STARTSWITH")
-               matchFlag = MATCH_STARTSWITH;
-       else if(matchFlagStr == "ENDSWITH")
-               matchFlag = MATCH_ENDSWITH;
-       else if(matchFlagStr == "EXISTS")
-               matchFlag = MATCH_EXISTS;
-       else
-               ThrowMsg(InvalidArgumentException, "FilterMatchFlag cannot have " << matchFlagStr);
-
-       return matchFlag;
-}
-
-JSValueRef FilterConverter::toJSValueRef(const SortOrder& arg)
-{
-       string sortOrderStr;
-
-       if(arg == ASCENDING_SORT_ORDER)
-               sortOrderStr = "ASC";
-       else if(arg == DESCENDING_SORT_ORDER)
-               sortOrderStr = "DESC";
-       else
-               ThrowMsg(ConversionException, "Can not create SortModeOrder.");
-
-       return toJSValueRef(sortOrderStr);
+       return JSValueMakeUndefined(m_context);
 }
 
-SortOrder FilterConverter::toSortOrder(const JSValueRef& arg)
+AnyPtr FilterConverter::toAny(const JSValueRef& arg, const string &attrName)
 {
-       if(arg == NULL)
-               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
-
-       if(!JSValueIsString(m_context, arg))
-               ThrowMsg(InvalidArgumentException, "Value is not an string.");
+       PrimitiveType type = PrimitiveType_NoType;
+       PropertyPtr property = findProperty(attrName);
+       if(property != NULL)
+               type = property->type;
+       else if(m_exception)
+               ThrowMsg(InvalidArgumentException, "Filter cannot have attribute name : " << attrName);
 
-       string sortOrderStr = toString(arg);
-       SortOrder sortOrder;
+       if(m_exception)
+               return AnyFactory::createAny(m_context, arg, type);
 
-       if(sortOrderStr == "ASC")
-               sortOrder = ASCENDING_SORT_ORDER;
-       else if(sortOrderStr == "DESC")
-               sortOrder = DESCENDING_SORT_ORDER;
-       else
-               ThrowMsg(InvalidArgumentException, "SortModeOrder cannot have " << sortOrderStr);
-
-       return sortOrder;
+       return AnyFactory::createAnyNoException(m_context, arg, type);
 }
 
-void FilterConverter::initFilterAttrs()
+void FilterConverter::toAnyCustom(const JSValueRef& arg, const std::string &attrName, AnyPtr& any) const
 {
-       m_compositeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_TYPE);
-       m_compositeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_FILTERS);
-
-       m_attributeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_ATTRIBUTE_NAME);
-       m_attributeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_FLAG);
-       m_attributeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_VALUES);
-
-       m_attributeRangeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_ATTRIBUTE_NAME);
-       m_attributeRangeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_INITIAL_VALUE);
-       m_attributeRangeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_END_VALUE);
-
-       m_sortModeAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_ORDER);
-       m_sortModeAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_ATTRIBUTE_NAME);
 }
 
 } // Tizen
index c282462..4b4ba87 100644 (file)
 #include <string>
 #include <CommonsJavaScript/Converter.h>
 #include "IFilter.h"
+#include "IFilterProperties.h"
 #include "CompositeFilter.h"
 #include "AttributeFilter.h"
 #include "AttributeRangeFilter.h"
 #include "SortMode.h"
+#include "AnyType.h"
 
-namespace DeviceAPI {\rnamespace Tizen {
+namespace DeviceAPI {
+namespace Tizen {
 
-class FilterConverter : public WrtDeviceApis::CommonsJavaScript::Converter
+class BaseFilterConverter : public WrtDeviceApis::CommonsJavaScript::Converter
 {
 public:
        using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef;
-public:
-       explicit FilterConverter(JSContextRef context);
-       virtual ~FilterConverter();
 
-       JSValueRef toJSValueRef(DeviceAPI::Tizen::FilterPtr arg);
-       DeviceAPI::Tizen::FilterPtr toFilter(const JSValueRef& arg);
+       explicit BaseFilterConverter(JSContextRef context);
+       virtual ~BaseFilterConverter();
+
+       JSValueRef toJSValueRef(const SortModePtr& arg);
+       SortModePtr toSortMode(const JSValueRef& arg);
 
-       JSValueRef toJSValueRef(const DeviceAPI::Tizen::FilterArrayPtr& arg);
-       DeviceAPI::Tizen::FilterArrayPtr toFilterArray(const JSValueRef& arg);
+       JSValueRef toJSValueRef(const SortModeArrayPtr& arg);
+       SortModeArrayPtr toSortModeArray(const JSValueRef& arg);
 
-       JSValueRef toJSValueRef(const DeviceAPI::Tizen::CompositeFilterPtr& arg);
-       DeviceAPI::Tizen::CompositeFilterPtr toCompositeFilter(const JSValueRef& arg);
+       JSValueRef toJSValueRef(const FilterType& arg);
+       FilterType toCompositeFilterType(const JSValueRef& arg);
+
+       JSValueRef toJSValueRef(const MatchFlag& arg);
+       MatchFlag toMatchFlag(const JSValueRef& arg);
+
+       JSValueRef toJSValueRef(const SortOrder& arg);
+       SortOrder toSortOrder(const JSValueRef& arg);
+};
 
-       JSValueRef toJSValueRef(const DeviceAPI::Tizen::AttributeFilterPtr& arg);
-       DeviceAPI::Tizen::AttributeFilterPtr toAttributeFilter(const JSValueRef& arg);
+class FilterConverter : public BaseFilterConverter, private IFilterProperties
+{
+public:
+       using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef;
 
-       JSValueRef toJSValueRef(const DeviceAPI::Tizen::AttributeRangeFilterPtr& arg);
-       DeviceAPI::Tizen::AttributeRangeFilterPtr toAttributeRangeFilter(const JSValueRef& arg);
+       explicit FilterConverter(JSContextRef context, PropertyStructArray properties, bool exception=false);
+       virtual ~FilterConverter();
 
-       JSValueRef toJSValueRef(const DeviceAPI::Tizen::SortModePtr& arg);
-       DeviceAPI::Tizen::SortModePtr toSortMode(const JSValueRef& arg);
+       JSValueRef toJSValueRef(FilterPtr arg);
+       FilterPtr toFilter(const JSValueRef& arg);
 
-       JSValueRef toJSValueRef(const DeviceAPI::Tizen::SortModeArrayPtr& arg);
-       DeviceAPI::Tizen::SortModeArrayPtr toSortModeArray(const JSValueRef& arg);
+       JSValueRef toJSValueRef(const FilterArrayPtr& arg);
+       FilterArrayPtr toFilterArray(const JSValueRef& arg);
 
-       JSValueRef toJSValueRef(const DeviceAPI::Tizen::AnyPtr& arg);
-       DeviceAPI::Tizen::AnyPtr toAny(const JSValueRef& arg);
+       JSValueRef toJSValueRef(const CompositeFilterPtr& arg);
+       CompositeFilterPtr toCompositeFilter(const JSValueRef& arg);
 
-       JSValueRef toJSValueRef(const DeviceAPI::Tizen::AnyArrayPtr& arg);
-       DeviceAPI::Tizen::AnyArrayPtr toAnyArray(const JSValueRef& arg);
+       JSValueRef toJSValueRef(const AttributeFilterPtr& arg);
+       AttributeFilterPtr toAttributeFilter(const JSValueRef& arg);
 
-       JSValueRef toJSValueRef(const DeviceAPI::Tizen::FilterType& arg);
-       DeviceAPI::Tizen::FilterType toCompositeFilterType(const JSValueRef& arg);
+       JSValueRef toJSValueRef(const AttributeRangeFilterPtr& arg);
+       AttributeRangeFilterPtr toAttributeRangeFilter(const JSValueRef& arg);
 
-       JSValueRef toJSValueRef(const DeviceAPI::Tizen::MatchFlag& arg);
-       DeviceAPI::Tizen::MatchFlag toMatchFlag(const JSValueRef& arg);
+       JSValueRef toJSValueRef(const AnyPtr &arg);
+       AnyPtr toAny(const JSValueRef& arg, const std::string &attrName);
 
-       JSValueRef toJSValueRef(const DeviceAPI::Tizen::SortOrder& arg);
-       DeviceAPI::Tizen::SortOrder toSortOrder(const JSValueRef& arg);
+       virtual void toAnyCustom(const JSValueRef& arg, const std::string &attrName, AnyPtr& any) const;
 
 private:
-       std::vector<std::string> m_compositeFilterAttrs;
-       std::vector<std::string> m_attributeFilterAttrs;
-       std::vector<std::string> m_attributeRangeFilterAttrs;
-       std::vector<std::string> m_sortModeAttrs;
-
-       void initFilterAttrs();
+       bool m_exception;
 };
 
-typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<FilterConverter> FilterConverterFactory;
+typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<BaseFilterConverter> FilterConverterFactory;
 
 } // Tizen
 } // DeviceAPI
 
-
 #endif // _TIZEN_FILTER_CONVERTER_H_
index 77e1de0..c5e6b39 100644 (file)
 #include <algorithm>
 #include "FilterValidator.h"
 
-namespace DeviceAPI {\rnamespace Tizen {
+namespace DeviceAPI {
+namespace Tizen {
 
 using namespace std;
 
-FilterValidator::FilterValidator(PropertyStructArray properties)
+FilterValidator::FilterValidator(PropertyStructArray properties) :
+               IFilterProperties(properties)
 {
-       int i;
-       for(i=0; properties[i].attributeName != 0 ; i++)
-               m_properties[properties[i].attributeName] =
-                               PropertyPtr(new Property(properties[i].type));
 }
 
 FilterValidator::~FilterValidator()
@@ -44,17 +42,24 @@ FilterValidator::~FilterValidator()
 bool FilterValidator::validateAttribute(std::string& attrName,
                MatchFlag& matchFlag, AnyPtr& matchValue, int depth)
 {
-       if(m_properties.find(attrName) == m_properties.end())
+       PropertyPtr prop = findProperty(attrName);
+       if(prop == NULL)
                return false;
 
        if(matchValue == NULL)
                return false;
 
-       PropertyPtr prop = m_properties[attrName];
-
        if(matchFlag == MATCH_EXISTS)
                return true;
 
+       if(prop->type == PrimitiveType_PlatformObject)
+       {
+               if(matchValue->getPriv() == NULL)
+                       return false;
+
+               return validateAttributeCustom(attrName, matchFlag, matchValue, depth);
+       }
+
        if(!matchValue->isType(prop->type))
                return false;
 
@@ -64,14 +69,13 @@ bool FilterValidator::validateAttribute(std::string& attrName,
 bool FilterValidator::validateAttributeRange(std::string& attrName,
                AnyPtr& initialValue, AnyPtr& endValue, int depth)
 {
-       if(initialValue == NULL || endValue == NULL)
+       PropertyPtr prop = findProperty(attrName);
+       if(prop == NULL)
                return false;
 
-       if(m_properties.find(attrName) == m_properties.end())
+       if(initialValue == NULL || endValue == NULL)
                return false;
 
-       PropertyPtr prop = m_properties[attrName];
-
        bool initialValueIsNull = initialValue->isNullOrUndefined();
        bool endValueIsNull = endValue->isNullOrUndefined();
 
@@ -79,6 +83,17 @@ bool FilterValidator::validateAttributeRange(std::string& attrName,
        if(initialValueIsNull && endValueIsNull)
                return false;
 
+       if(prop->type == PrimitiveType_PlatformObject)
+       {
+               if(!initialValueIsNull && initialValue->getPriv() == NULL)
+                       return false;
+
+               if(!endValue && endValue->getPriv() == NULL)
+                       return false;
+
+               return validateAttributeRangeCustom(attrName, initialValue, endValue, depth);
+       }
+
        if(!initialValueIsNull && !initialValue->isType(prop->type))
                return false;
 
@@ -93,5 +108,17 @@ bool FilterValidator::validateComposite(int depth)
        return true;
 }
 
+bool FilterValidator::validateAttributeCustom(std::string& attrName,
+               MatchFlag& matchFlag, AnyPtr& matchValue, int depth)
+{
+       return true;
+}
+
+bool FilterValidator::validateAttributeRangeCustom(std::string& attrName,
+               AnyPtr& initialValue, AnyPtr& endValue, int depth)
+{
+       return true;
+}
+
 } // Tizen
 } // DeviceAPI
index 9156611..1110cd7 100644 (file)
 #include <vector>
 #include <string>
 #include <dpl/shared_ptr.h>
+#include "IFilterProperties.h"
 #include "FilterTypes.h"
 #include "AnyType.h"
 
-namespace DeviceAPI {\rnamespace Tizen {
+namespace DeviceAPI {
+namespace Tizen {
 
 class IFilter;
 typedef DPL::SharedPtr<IFilter> FilterPtr;
 typedef std::vector<std::string> MatchFlagArray;
 typedef DPL::SharedPtr<MatchFlagArray> MatchFlagArrayPtr;
 
-struct PropertyStruct
-{
-       const char * attributeName;
-    const PrimitiveType type;
-};
-typedef PropertyStruct PropertyStructArray[];
-
 // GoF Visitor Pattern
-class FilterValidator
+class FilterValidator : private IFilterProperties
 {
-private:
-       class Property
-       {
-       public:
-               Property(PrimitiveType pType) :
-                       type(pType) {}
-               PrimitiveType type;
-       };
-       typedef DPL::SharedPtr<Property> PropertyPtr;
-       typedef std::map<std::string, PropertyPtr> PropertyMap;
-
-       PropertyMap                             m_properties;
-
 public:
        FilterValidator(PropertyStructArray properties);
 
        virtual ~FilterValidator();
 
        // validate AttributeFilter
-       virtual bool validateAttribute(std::string& attrName,
+       bool validateAttribute(std::string& attrName,
                        MatchFlag& matchFlag, AnyPtr& matchValue, int depth=0);
 
        // validate AttributeRangeFilter
-       virtual bool validateAttributeRange(std::string& attrName,
+       bool validateAttributeRange(std::string& attrName,
                        AnyPtr& initialValue, AnyPtr& endValue, int depth=0);
 
        // validate CompositeFilter
-       virtual bool validateComposite(int depth=0);
+       bool validateComposite(int depth=0);
+
+protected:
+       // If type is PrimitiveType_PlatformObject or PrimitiveType_Custom,
+       // validateAttributeCustom function would be called to validate the attribute.
+       // Developer can override this function to validate the attribute.
+       virtual bool validateAttributeCustom(std::string& attrName,
+                       MatchFlag& matchFlag, AnyPtr& matchValue, int depth);
+
+       // If type is PrimitiveType_PlatformObject or PrimitiveType_Custom,
+       // validateAttributeRangeCustom function would be called to validate the attribute.
+       // Developer can override this function to validate the attribute.
+       virtual bool validateAttributeRangeCustom(std::string& attrName,
+                       AnyPtr& initialValue, AnyPtr& endValue, int depth);
 };
 
 typedef DPL::SharedPtr<FilterValidator> FilterValidatorPtr;
diff --git a/src/Tizen/IFilterProperties.cpp b/src/Tizen/IFilterProperties.cpp
new file mode 100644 (file)
index 0000000..cdad694
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file       IFilterProperties.cpp
+ * @author     Kisub Song (kisubs.song@samsung.com)
+ * @version    0.1
+ * @brief
+ */
+
+#include "IFilterProperties.h"
+
+namespace DeviceAPI {
+namespace Tizen {
+
+using namespace std;
+
+IFilterProperties::IFilterProperties(PropertyStructArray properties)
+{
+       int i;
+       for(i=0; properties[i].attributeName != 0 ; i++)
+               m_properties[properties[i].attributeName] =
+                               PropertyPtr(new Property(properties[i].type));
+}
+
+IFilterProperties::~IFilterProperties()
+{
+}
+
+IFilterProperties::PropertyPtr IFilterProperties::findProperty(const std::string& attrName) const
+{
+       PropertyMap::const_iterator iter = m_properties.find(attrName);
+       if(iter == m_properties.end())
+               return PropertyPtr(NULL);
+
+       return iter->second;
+}
+
+} // Tizen
+} // DeviceAPI
diff --git a/src/Tizen/IFilterProperties.h b/src/Tizen/IFilterProperties.h
new file mode 100644 (file)
index 0000000..5ddd6e0
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+/**
+ * @file       IFilterProperties.h
+ * @author     Kisub Song (kisubs.song@samsung.com)
+ * @version    0.1
+ * @brief
+ */
+
+#ifndef _API_IFILTER_PROPERTIES_H_
+#define _API_IFILTER_PROPERTIES_H_
+
+#include <map>
+#include <vector>
+#include <string>
+#include <dpl/shared_ptr.h>
+#include "AnyType.h"
+
+namespace DeviceAPI {
+namespace Tizen {
+
+struct PropertyStruct
+{
+       const char * attributeName;
+    const PrimitiveType type;
+};
+typedef PropertyStruct PropertyStructArray[];
+
+class IFilterProperties
+{
+protected:
+       class Property
+       {
+       public:
+               Property(PrimitiveType pType) :
+                       type(pType) {}
+               PrimitiveType type;
+       };
+       typedef DPL::SharedPtr<Property> PropertyPtr;
+
+private:
+       typedef std::map<std::string, PropertyPtr> PropertyMap;
+       PropertyMap m_properties;
+
+public:
+       IFilterProperties(PropertyStructArray properties);
+       virtual ~IFilterProperties();
+
+protected:
+       PropertyPtr findProperty(const std::string &attrName) const;
+};
+
+} // Tizen
+} // DeviceAPI
+
+#endif // _API_IFILTER_PROPERTIES_H_
index 14d562c..18cfc79 100644 (file)
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
 #include <JSTizenExceptionFactory.h>
 #include <JSTizenException.h>
 #include "AttributeFilter.h"
 #include "FilterConverter.h"
 #include "JSAttributeFilter.h"
+#include "AnyFactory.h"
 
 #define ATTRIBUTE_FILTER_CLASS_NAME "AttributeFilter"
 
@@ -39,7 +41,8 @@
 #define ATTRIBUTE_FILTER_ATTR_MATCH_FLAG "matchFlag"
 #define ATTRIBUTE_FILTER_ATTR_MATCH_VALUE "matchValue"
 
-namespace DeviceAPI {\rnamespace Tizen {
+namespace DeviceAPI {
+namespace Tizen {
 
 using namespace DeviceAPI::Common;
 using namespace DeviceAPI::Tizen;
@@ -72,7 +75,6 @@ JSClassDefinition JSAttributeFilter::m_classInfo =
 JSStaticValue JSAttributeFilter::m_property[] = {
        { ATTRIBUTE_FILTER_ATTR_ATTRIBUTE_NAME, getAttributeName, setAttributeName, kJSPropertyAttributeNone },
        { ATTRIBUTE_FILTER_ATTR_MATCH_FLAG, getMatchFlag, setMatchFlag, kJSPropertyAttributeNone },
-       { ATTRIBUTE_FILTER_ATTR_MATCH_VALUE, getMatchValue, setMatchValue, kJSPropertyAttributeNone },
        { 0, 0, 0, 0 }
 };
 
@@ -109,7 +111,7 @@ AttributeFilterPtr JSAttributeFilter::getAttributeFilter(JSContextRef context, J
        return priv->getObject();
 }
 
-JSObjectRef JSAttributeFilter::createJSObject(JSContextRef context, AttributeFilterPtr privateData)
+JSObjectRef JSAttributeFilter::createJSObject(JSContextRef context, AttributeFilterPtr privateData, JSValueRef jsValueMatchValue)
 {
        JSAttributeFilterPriv *priv = new JSAttributeFilterPriv(context, privateData);
        JSObjectRef jsObjectRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
@@ -117,6 +119,13 @@ JSObjectRef JSAttributeFilter::createJSObject(JSContextRef context, AttributeFil
                LogError("object creation error");
                return NULL;
        }
+
+       FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(context);
+
+       const ScopedJSStringRef jsStrMatchValue(JSStringCreateWithUTF8CString(ATTRIBUTE_FILTER_ATTR_MATCH_VALUE));
+
+       JSObjectSetProperty(context, jsObjectRef, jsStrMatchValue.get(), jsValueMatchValue, kJSPropertyAttributeNone, NULL);
+
        return jsObjectRef;
 }
 
@@ -152,7 +161,7 @@ JSObjectRef JSAttributeFilter::constructor(JSContextRef context,
 
                if (argumentCount >= 3)
                {
-                       if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2]))
+                       if (!JSValueIsUndefined(context, arguments[2]))
                                js3rdParamIsValue = true;
                }
 
@@ -189,24 +198,20 @@ JSObjectRef JSAttributeFilter::constructor(JSContextRef context,
                return NULL;
        }
 
-       Try {
-               if(js3rdParamIsValue)
-                       matchValue = converter->toAny(arguments[2]);
-               else
-                       matchValue = AnyPtr(new Any());
-
-       } Catch(Exception) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
-               return NULL;
-       }
+       matchValue = AnyFactory::createAnyEmpty(context);
 
        AttributeFilterPtr attributeFilter(new AttributeFilter(attributeName, matchFlag, matchValue));
 
+       JSValueRef jsValueMatchValue = NULL;
+       if(js3rdParamIsValue)
+               jsValueMatchValue = arguments[2];
+       else
+               jsValueMatchValue = JSValueMakeUndefined(context);
+
        JSObjectRef jsobject;
 
        Try {
-               jsobject = createJSObject(context, attributeFilter);
+               jsobject = createJSObject(context, attributeFilter, jsValueMatchValue);
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
@@ -340,50 +345,6 @@ bool JSAttributeFilter::setMatchFlag(JSContextRef context,
        return false;
 }
 
-JSValueRef JSAttributeFilter::getMatchValue(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-       LogDebug("entered");
-       Try
-       {
-               FilterConverterFactory::ConverterType converter =
-                               FilterConverterFactory::getConverter(context);
-               AttributeFilterPtr attributeFilter = getPrivData(object);
-               return converter->toJSValueRef(attributeFilter->getMatchValue());
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to get incorrect value");
-       }
-
-       return JSValueMakeUndefined(context);
-}
-
-bool JSAttributeFilter::setMatchValue(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef value,
-               JSValueRef* exception)
-{
-       Try
-       {
-               AttributeFilterPtr attributeFilter = getPrivData(object);
-               FilterConverterFactory::ConverterType converter =
-                               FilterConverterFactory::getConverter(context);
-               attributeFilter->setMatchValue(converter->toAny(value));
-               return true;
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to set incorrect value");
-       }
-
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
-}
-
 } // Tizen
 } // DeviceAPI
 
index c699566..2090ab6 100644 (file)
@@ -31,7 +31,8 @@
 #include <Commons/IEvent.h>
 #include "AttributeFilter.h"
 
-namespace DeviceAPI {\rnamespace Tizen {
+namespace DeviceAPI {
+namespace Tizen {
 
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<DeviceAPI::Tizen::AttributeFilterPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSAttributeFilterPriv;
 
@@ -46,7 +47,9 @@ public:
 
        static DeviceAPI::Tizen::AttributeFilterPtr getAttributeFilter(JSContextRef context, JSValueRef value);
 
-       static JSObjectRef createJSObject(JSContextRef context, DeviceAPI::Tizen::AttributeFilterPtr privateData);
+       static JSObjectRef createJSObject(JSContextRef context,
+                       DeviceAPI::Tizen::AttributeFilterPtr privateData,
+                       JSValueRef jsValueMatchValue);
 
        static JSObjectRef constructor(JSContextRef context,
                        JSObjectRef constructor,
@@ -106,17 +109,6 @@ private:
                        JSStringRef propertyName,
                        JSValueRef value,
                        JSValueRef* exception);
-
-       static JSValueRef getMatchValue(JSContextRef context,
-                       JSObjectRef object,
-                       JSStringRef propertyName,
-                       JSValueRef* exception);
-
-       static bool setMatchValue(JSContextRef context,
-                       JSObjectRef object,
-                       JSStringRef propertyName,
-                       JSValueRef value,
-                       JSValueRef* exception);
 };
 
 } // Tizen
index 19a7814..9617023 100644 (file)
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
 #include <JSTizenExceptionFactory.h>
 #include <JSTizenException.h>
 #include "AttributeRangeFilter.h"
 #include "FilterConverter.h"
 #include "JSAttributeRangeFilter.h"
+#include "AnyFactory.h"
 
 #define ATTRIBUTE_RANGE_FILTER_CLASS_NAME "AttributeRangeFilter"
 
@@ -38,7 +40,8 @@
 #define ATTRIBUTE_FILTER_ATTR_INITIAL_VALUE "initialValue"
 #define ATTRIBUTE_FILTER_ATTR_END_VALUE "endValue"
 
-namespace DeviceAPI {\rnamespace Tizen {
+namespace DeviceAPI {
+namespace Tizen {
 
 using namespace DeviceAPI::Common;
 using namespace DeviceAPI::Tizen;
@@ -70,8 +73,6 @@ JSClassDefinition JSAttributeRangeFilter::m_classInfo =
 
 JSStaticValue JSAttributeRangeFilter::m_property[] = {
        { ATTRIBUTE_FILTER_ATTR_ATTRIBUTE_NAME, getAttributeName, setAttributeName, kJSPropertyAttributeNone },
-       { ATTRIBUTE_FILTER_ATTR_INITIAL_VALUE, getInitialValue, setInitialValue, kJSPropertyAttributeNone },
-       { ATTRIBUTE_FILTER_ATTR_END_VALUE, getEndValue, setEndValue, kJSPropertyAttributeNone },
        { 0, 0, 0, 0 }
 };
 
@@ -108,7 +109,10 @@ AttributeRangeFilterPtr JSAttributeRangeFilter::getAttributeRangeFilter(JSContex
        return priv->getObject();
 }
 
-JSObjectRef JSAttributeRangeFilter::createJSObject(JSContextRef context, AttributeRangeFilterPtr privateData)
+JSObjectRef JSAttributeRangeFilter::createJSObject(JSContextRef context,
+               AttributeRangeFilterPtr privateData,
+               JSValueRef jsValueInitialValue,
+               JSValueRef jsValueEndValue)
 {
        JSAttributeRangeFilterPriv *priv = new JSAttributeRangeFilterPriv(context, privateData);
        JSObjectRef jsObjectRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
@@ -116,6 +120,15 @@ JSObjectRef JSAttributeRangeFilter::createJSObject(JSContextRef context, Attribu
                LogError("object creation error");
                return NULL;
        }
+
+       FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(context);
+
+       const ScopedJSStringRef jsStrInitialValue(JSStringCreateWithUTF8CString(ATTRIBUTE_FILTER_ATTR_INITIAL_VALUE));
+       const ScopedJSStringRef jsStrEndValue(JSStringCreateWithUTF8CString(ATTRIBUTE_FILTER_ATTR_END_VALUE));
+
+       JSObjectSetProperty(context, jsObjectRef, jsStrInitialValue.get(), jsValueInitialValue, kJSPropertyAttributeNone, NULL);
+       JSObjectSetProperty(context, jsObjectRef, jsStrEndValue.get(), jsValueEndValue, kJSPropertyAttributeNone, NULL);
+
        return jsObjectRef;
 }
 
@@ -141,13 +154,13 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
                // 2nd and 3rd argument can be any type.
                if (argumentCount >= 2)
                {
-                       if(!JSValueIsUndefined(context, arguments[1]) && !JSValueIsNull(context, arguments[1]))
+                       if(!JSValueIsUndefined(context, arguments[1]))
                                js2ndParamIsValue = true;
                }
 
                if (argumentCount >= 3)
                {
-                       if(!JSValueIsUndefined(context, arguments[2]) && !JSValueIsNull(context, arguments[2]))
+                       if(!JSValueIsUndefined(context, arguments[2]))
                                js3rdParamIsValue = true;
                }
 
@@ -171,36 +184,27 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
                return NULL;
        }
 
-       Try {
-               if(js2ndParamIsValue)
-                       initialValue = converter->toAny(arguments[1]);
-               else
-                       initialValue = AnyPtr(new Any());
+       initialValue = AnyFactory::createAnyEmpty(context);
+       endValue = AnyFactory::createAnyEmpty(context);
 
-       } Catch(Exception) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
-               return NULL;
-       }
-
-       Try {
-               if(js3rdParamIsValue)
-                       endValue = converter->toAny(arguments[2]);
-               else
-                       endValue = AnyPtr(new Any());
+       AttributeRangeFilterPtr attributeRangeFilter(new AttributeRangeFilter(attributeName, initialValue, endValue));
 
-       } Catch(Exception) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
-               return NULL;
-       }
+       JSValueRef jsValueInitialValue = NULL;
+       if(js2ndParamIsValue)
+               jsValueInitialValue = arguments[1];
+       else
+               jsValueInitialValue = JSValueMakeUndefined(context);
 
-       AttributeRangeFilterPtr attributeRangeFilter(new AttributeRangeFilter(attributeName, initialValue, endValue));
+       JSValueRef jsValueEndValue = NULL;
+       if(js3rdParamIsValue)
+               jsValueEndValue = arguments[2];
+       else
+               jsValueEndValue = JSValueMakeUndefined(context);
 
        JSObjectRef jsobject;
 
        Try {
-               jsobject = createJSObject(context, attributeRangeFilter);
+               jsobject = createJSObject(context, attributeRangeFilter, jsValueInitialValue, jsValueEndValue);
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
@@ -291,92 +295,6 @@ bool JSAttributeRangeFilter::setAttributeName(JSContextRef context,
        return false;
 }
 
-JSValueRef JSAttributeRangeFilter::getInitialValue(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-       LogDebug("entered");
-       Try
-       {
-               FilterConverterFactory::ConverterType converter =
-                               FilterConverterFactory::getConverter(context);
-               AttributeRangeFilterPtr attributeRangeFilter = getPrivData(object);
-               return converter->toJSValueRef(attributeRangeFilter->getInitialValue());
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to get incorrect value");
-       }
-       return JSValueMakeUndefined(context);
-}
-
-bool JSAttributeRangeFilter::setInitialValue(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef value,
-               JSValueRef* exception)
-{
-       Try
-       {
-               AttributeRangeFilterPtr attributeRangeFilter = getPrivData(object);
-               FilterConverterFactory::ConverterType converter =
-                               FilterConverterFactory::getConverter(context);
-               attributeRangeFilter->setInitialValue(converter->toAny(value));
-               return true;
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to set incorrect value");
-       }
-
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
-}
-
-JSValueRef JSAttributeRangeFilter::getEndValue(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-       LogDebug("entered");
-       Try
-       {
-               FilterConverterFactory::ConverterType converter =
-                               FilterConverterFactory::getConverter(context);
-               AttributeRangeFilterPtr attributeRangeFilter = getPrivData(object);
-               return converter->toJSValueRef(attributeRangeFilter->getEndValue());
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to get incorrect value");
-       }
-       return JSValueMakeUndefined(context);
-}
-
-bool JSAttributeRangeFilter::setEndValue(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef value,
-               JSValueRef* exception)
-{
-       Try
-       {
-               AttributeRangeFilterPtr attributeRangeFilter = getPrivData(object);
-               FilterConverterFactory::ConverterType converter =
-                               FilterConverterFactory::getConverter(context);
-               attributeRangeFilter->setEndValue(converter->toAny(value));
-               return true;
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to set incorrect value");
-       }
-
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
-}
-
 } // Tizen
 } // DeviceAPI
 
index 6621170..8c1c0da 100644 (file)
@@ -31,7 +31,8 @@
 #include <Commons/IEvent.h>
 #include "AttributeRangeFilter.h"
 
-namespace DeviceAPI {\rnamespace Tizen {
+namespace DeviceAPI {
+namespace Tizen {
 
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<DeviceAPI::Tizen::AttributeRangeFilterPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSAttributeRangeFilterPriv;
 
@@ -47,7 +48,9 @@ public:
        static DeviceAPI::Tizen::AttributeRangeFilterPtr getAttributeRangeFilter(JSContextRef context, JSValueRef value);
 
        static JSObjectRef createJSObject(JSContextRef context,
-                       DeviceAPI::Tizen::AttributeRangeFilterPtr privateData);
+                       DeviceAPI::Tizen::AttributeRangeFilterPtr privateData,
+                       JSValueRef jsValueInitialValue,
+                       JSValueRef jsValueEndValue);
 
        static JSObjectRef constructor(JSContextRef context,
                        JSObjectRef constructor,
@@ -96,28 +99,6 @@ private:
                        JSStringRef propertyName,
                        JSValueRef value,
                        JSValueRef* exception);
-
-       static JSValueRef getInitialValue(JSContextRef context,
-                       JSObjectRef object,
-                       JSStringRef propertyName,
-                       JSValueRef* exception);
-
-       static bool setInitialValue(JSContextRef context,
-                       JSObjectRef object,
-                       JSStringRef propertyName,
-                       JSValueRef value,
-                       JSValueRef* exception);
-
-       static JSValueRef getEndValue(JSContextRef context,
-                       JSObjectRef object,
-                       JSStringRef propertyName,
-                       JSValueRef* exception);
-
-       static bool setEndValue(JSContextRef context,
-                       JSObjectRef object,
-                       JSStringRef propertyName,
-                       JSValueRef value,
-                       JSValueRef* exception);
 };
 
 } // Tizen
index 5645760..80afe13 100644 (file)
@@ -39,7 +39,8 @@
 #define ATTRIBUTE_FILTER_ATTR_TYPE "type"
 #define ATTRIBUTE_FILTER_ATTR_FILTERS "filters"
 
-namespace DeviceAPI {\rnamespace Tizen {
+namespace DeviceAPI {
+namespace Tizen {
 
 using namespace DeviceAPI::Common;
 using namespace DeviceAPI::Tizen;
@@ -108,7 +109,7 @@ CompositeFilterPtr JSCompositeFilter::getCompositeFilter(JSContextRef context, J
        return priv->getObject();
 }
 
-JSObjectRef JSCompositeFilter::createJSObject(JSContextRef context, CompositeFilterPtr privateData)
+JSObjectRef JSCompositeFilter::createJSObject(JSContextRef context, CompositeFilterPtr privateData, JSValueRef jsValueFilters)
 {
        JSCompositeFilterPriv *priv = new JSCompositeFilterPriv(context, privateData);
        JSObjectRef jsObjectRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
@@ -117,10 +118,7 @@ JSObjectRef JSCompositeFilter::createJSObject(JSContextRef context, CompositeFil
                return NULL;
        }
 
-       FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(context);
-
        const ScopedJSStringRef jsStrFilters(JSStringCreateWithUTF8CString(ATTRIBUTE_FILTER_ATTR_FILTERS));
-       JSValueRef jsValueFilters =     converter->toJSValueRef(privateData->getFilters());
 
        JSObjectSetProperty(context, jsObjectRef, jsStrFilters.get(), jsValueFilters, kJSPropertyAttributeNone, NULL);
 
@@ -135,7 +133,7 @@ JSObjectRef JSCompositeFilter::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-       bool js2ndParamIsObject = false;
+       bool js2ndParamIsArray = false;
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
@@ -147,10 +145,10 @@ JSObjectRef JSCompositeFilter::constructor(JSContextRef context,
 
                if (argumentCount >= 2)
                {
-                       if (JSValueIsObject(context, arguments[1]))
-                               js2ndParamIsObject = true;
+                       if (JSIsArrayValue(context, arguments[1]))
+                               js2ndParamIsArray = true;
 
-                       if (!js2ndParamIsObject &&
+                       if (!js2ndParamIsArray &&
                                        !JSValueIsNull(context, arguments[1]) &&
                                        !JSValueIsUndefined(context, arguments[1]))
                                ThrowMsg(InvalidArgumentException, "2nd argument is not array.");
@@ -175,24 +173,18 @@ JSObjectRef JSCompositeFilter::constructor(JSContextRef context,
                return NULL;
        }
 
-       Try {
-               if(js2ndParamIsObject)
-                       filters = converter->toFilterArray(arguments[1]);
-               else
-                       filters = FilterArrayPtr(new FilterArray());
+       JSValueRef jsValueFilters = NULL;
+       if(js2ndParamIsArray)
+               jsValueFilters = arguments[1];
+       else
+               jsValueFilters = JSCreateArrayObject(context, 0, NULL);
 
-       } Catch(Exception) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
-               return NULL;
-       }
-
-       CompositeFilterPtr compositeFilter(new CompositeFilter(type, filters));
+       CompositeFilterPtr compositeFilter(new CompositeFilter(type, FilterArrayPtr(new FilterArray())));
 
        JSObjectRef jsobject;
 
        Try {
-               jsobject = createJSObject(context, compositeFilter);
+               jsobject = createJSObject(context, compositeFilter, jsValueFilters);
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
@@ -402,49 +394,6 @@ bool JSCompositeFilter::setType(JSContextRef context,
        return false;
 }
 
-//JSValueRef JSCompositeFilter::getFilters(JSContextRef context,
-//             JSObjectRef object,
-//             JSStringRef propertyName,
-//             JSValueRef* exception)
-//{
-//     LogDebug("entered");
-//     Try
-//     {
-//             FilterConverterFactory::ConverterType converter =
-//                             FilterConverterFactory::getConverter(context);
-//             CompositeFilterPtr compositeFilter = getPrivData(object);
-//             return converter->toJSValueRef(compositeFilter->getFilters());
-//     }
-//     Catch(WrtDeviceApis::Commons::Exception)
-//     {
-//             LogWarning("trying to get incorrect value");
-//     }
-//     return JSValueMakeUndefined(context);
-//}
-
-//bool JSCompositeFilter::setFilters(JSContextRef context,
-//             JSObjectRef object,
-//             JSStringRef propertyName,
-//             JSValueRef value,
-//             JSValueRef* exception)
-//{
-//     Try
-//     {
-//             CompositeFilterPtr compositeFilter = getPrivData(object);
-//             FilterConverterFactory::ConverterType converter =
-//                             FilterConverterFactory::getConverter(context);
-//             compositeFilter->setFilters(converter->toFilterArray(value));
-//             return true;
-//     }
-//     Catch(WrtDeviceApis::Commons::Exception)
-//     {
-//             LogWarning("trying to set incorrect value");
-//     }
-//
-//     JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-//     return false;
-//}
-//
 } // Tizen
 } // DeviceAPI
 
index 9bb43fd..440f501 100644 (file)
@@ -31,7 +31,8 @@
 #include <Commons/IEvent.h>
 #include "CompositeFilter.h"
 
-namespace DeviceAPI {\rnamespace Tizen {
+namespace DeviceAPI {
+namespace Tizen {
 
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<DeviceAPI::Tizen::CompositeFilterPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSCompositeFilterPriv;
 
@@ -46,7 +47,9 @@ public:
 
        static DeviceAPI::Tizen::CompositeFilterPtr getCompositeFilter(JSContextRef context, JSValueRef value);
 
-       static JSObjectRef createJSObject(JSContextRef context, DeviceAPI::Tizen::CompositeFilterPtr privateData);
+       static JSObjectRef createJSObject(JSContextRef context,
+                       DeviceAPI::Tizen::CompositeFilterPtr privateData,
+                       JSValueRef jsValueFilters);
 
        static JSObjectRef constructor(JSContextRef context,
                        JSObjectRef constructor,
@@ -119,17 +122,6 @@ private:
                        JSStringRef propertyName,
                        JSValueRef value,
                        JSValueRef* exception);
-
-//     static JSValueRef getFilters(JSContextRef context,
-//                     JSObjectRef object,
-//                     JSStringRef propertyName,
-//                     JSValueRef* exception);
-
-//     static bool setFilters(JSContextRef context,
-//                     JSObjectRef object,
-//                     JSStringRef propertyName,
-//                     JSValueRef value,
-//                     JSValueRef* exception);
 };
 
 } // Tizen