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
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}
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
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}
TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME}
${LIBS_COMMON}
${platform_pkgs_alarm_LIBRARIES}
- ${application_impl}
${tizen_impl}
+ ${application_impl}
+ ${timeutil_impl}
)
SET(SRCS
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}
)
namespace DeviceAPI {
namespace Bookmark {
-#define UNDEFINED_ID 0
-#define ROOTFOLDER_ID 1
+#define UNDEFINED_ID -1
enum bookmarkType {
BOOKMARKITEM_TYPE = 0,
}
BookmarkManager::BookmarkManager(){
- rootFolderId = 1;
+ rootFolderId = 0;
favorites_bookmark_get_root_folder_id(&rootFolderId);
}
BookmarkManager::~BookmarkManager(){
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);
}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){
throw TypeMismatchException("Parent Folder private data is null");
}
- int parentId = 0;
+ int parentId = UNDEFINED_ID;
if (parentFolder)
parentId = parentFolder->m_id;
else
)
add_subdir(Common/StandaloneConsole)
+add_subdir(Common/TimeTracer)
set(LIBS_TEST
${LIBS_COMMON}
"standaloneconsole"
+ "timetracer"
)
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
add_plugin(
- TimeUtil
Tizen
+ TimeUtil
Content
Calendar
Contact
SET(SRCS_IMPL
CalendarResponseDispatcher.cpp
CalendarConverter.cpp
+ CalendarFilterConverter.cpp
JSCalendarEvent.cpp
JSCalendarTask.cpp
JSCalendarItemProperties.cpp
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);
} 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);
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)));
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),
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();
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
#include "EventRecurrenceRule.h"
#include <JavaScriptCore/JavaScript.h>
+#include "SimpleCoordinates.h"
namespace DeviceAPI {
namespace Calendar {
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;
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;
#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"
m_normalInstanceRecordCount = 0;
m_alldayInstanceRecordList = NULL;
m_alldayInstanceRecordCount = 0;
+ m_calendarId = UNDEFINED_CALENDAR_ID;
}
CalendarFilter::~CalendarFilter()
|| CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY==attrName) {
value = convertStringToIntValue(attrName, matchValue->getString());
} else {
- value = matchValue->getInt();
+ value = matchValue->getLong();
}
if(CalendarEvent::TASK_TYPE==m_type) {
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 {
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);
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);
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;
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);
} 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);
LogDebug("Allday instance item count: "<<m_alldayInstanceRecordCount);
}
+
+
LogDebug("Free queries and filters.");
if(normalQuery) {
calendar_query_destroy(normalQuery);
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);
}
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;
return -1;
}
+std::time_t CalendarFilter::getTimeTFromTZDateAny(DeviceAPI::Tizen::AnyPtr &any) const
+{
+ std::time_t *pt = static_cast<time_t*>(any->getPriv());
+
+ return *pt;
+}
+
}
}
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;
void setType(CalendarEvent::CalendarType type);
void setCalendarId(int calendarId, bool isFilterSet);
+ void setCalendarIdForEvent(int calendarId);
void setSortMode(DeviceAPI::Tizen::SortModeArrayPtr attr);
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;
--- /dev/null
+//
+// 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
+
--- /dev/null
+//
+// 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_
+
#include "CalendarFilterValidator.h"
#include "CalendarFilter.h"
+#include <JSTZDate.h>
namespace DeviceAPI {
namespace Calendar {
{
{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},
{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},
{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;
}
LogDebug("Unprotect JS daysOfTheWeek.");
JSValueUnprotect(m_context, m_daysOfTheWeekJSRef);
}
- if(m_daysOfTheWeekJSRef) {
+ if(m_setPositionsJSRef) {
LogDebug("Unprotect JS setPositions.");
JSValueUnprotect(m_context, m_setPositionsJSRef);
}
{
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) {
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);
LogWarning("Can't get item longitude.");
return;
}
- m_abstractEvent->setLongitude(value);
+ m_abstractEvent->getGeolocation()->setLongitude(value);
}
void EventWrapper::setPriorityFromPlatformEvent()
#include <JSTizenException.h>
#include <JSTizenExceptionFactory.h>
#include <SecurityExceptions.h>
-#include <FilterConverter.h>
#include <TimeUtilConverter.h>
#include "JSCalendarManager.h"
#include "plugin_config.h"
#include "CalendarResponseDispatcher.h"
#include "CalendarMultiCallback.h"
+#include "CalendarFilterConverter.h"
#include "CalendarAsyncCallbackManager.h"
#include "CalendarListenerManager.h"
};
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 }
};
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.");
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
}
- DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
- return false;
+
+ return true;
}
}
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
}
- JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
- return false;
+
+ return true;
}
}
};
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 }
};
Catch(Exception)
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
- DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
}
- return false;
+ return true;
}
}
#include <JSTZDate.h>
#include <sstream>
-
using namespace WrtDeviceApis::Commons;
using namespace WrtDeviceApis::CommonsJavaScript;
using namespace DeviceAPI::Common;
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
}
- JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
- return false;
+
+ return true;
}
}
{ 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 }
};
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,
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,
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,
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,
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,
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,
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,
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,
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,
{
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)
{
{
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
{ 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 }
};
{
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
}
- JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
- return false;
+
+ return true;
}
}
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 }
};
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}
)
CallHistory.cpp
CallHistoryEntry.cpp
CallHistoryFilter.cpp
+ CallHistoryFilterConverter.cpp
CallHistoryMultiCallback.cpp
CallHistoryStaticController.cpp
CallHistoryListenerManager.cpp
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());
}
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);
tokenType = strtok( NULL, seps );
}
-
+
if((changeType == CONTACTS_CHANGE_INSERTED)||(changeType == CONTACTS_CHANGE_UPDATED)){
if (callHistoryListPtr->size() > 0) {
setCurrentLogId((*callHistoryListPtr)[0]->getEntryId());
}else if(changeType == CONTACTS_CHANGE_UPDATED){
stateHasChanged(callHistoryListPtr, EventCallHistoryListener::CHANGED);
}
-
+
}
}else if(changeType == CONTACTS_CHANGE_DELETED){
stateHasRemoved(RemoveListPtr, EventCallHistoryListener::REMOVED);
}
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);
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);
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);
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);
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);
}
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 << "]");
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 << "]");
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 {
--- /dev/null
+//
+// 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
+
--- /dev/null
+//
+// 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_
+
#include "plugin_config.h"
#include "CallHistoryAsyncCallbackManager.h"
#include "CallHistoryListenerManager.h"
-
+#include "CallHistoryFilterConverter.h"
using namespace std;
cbm->setObject(thisObject);
- FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+ CallHistoryFilterConverterFactory::ConverterType filterConverter =
+ CallHistoryFilterConverterFactory::getConverter(context);
EventFindCallHistoryPtr event(new EventFindCallHistory());
ICallHistoryPtr callHistory(priv->getObject());
JSWebAPIErrorFactory.cpp
JSWebAPIError2.cpp
WebAPIError.cpp
+ PropertyBag.cpp
)
ADD_LIBRARY(${COMMON_TARGET_NAME} SHARED ${SRCS})
#include "MultiCallbackUserData.h"
#include "GlobalContextManager.h"
#include "PlatformException.h"
-#include "Logger.h"
#include "JSUtil.h"
+#include "Logger.h"
using namespace std;
if( itr != mCallbacks.end() && itr->second != NULL){
JSValueUnprotect(mContext, itr->second);
}
-
+
if( callback != NULL ){
JSValueProtect(mContext, callback);
}
-
+
mCallbacks[key] = callback;
}
LOGE("There is no such callback[%s]", key.c_str());
return;
}
-
+
if( itr->second ){
JSObjectCallAsFunction(mContext, itr->second , NULL, count, obj, NULL);
}else{
#include <JavaScriptCore/JavaScript.h>
#include <string>
#include <map>
+#include <boost/shared_ptr.hpp>
namespace DeviceAPI {
namespace Common{
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;
std::map<const std::string, JSObjectRef> mCallbacks;
};
+typedef boost::shared_ptr<MultiCallbackUserData> MultiCallbackUserDataPtr;
+
}
}
--- /dev/null
+//
+// 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
--- /dev/null
+//
+// 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__
--- /dev/null
+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
+)
+
--- /dev/null
+//
+// 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);
+}
--- /dev/null
+//
+// 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__
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}
)
ContactObjectP2AConverter.cpp
ContactsSvcObjectConverter.cpp
ContactSearchEngine.cpp
+ ContactFilterConverter.cpp
ContactFilterValidator.cpp
ContactsSvcChangeListenerManager.cpp
ContactsSvcWrapper.cpp
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;
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);
}
--- /dev/null
+//
+// 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
+
--- /dev/null
+//
+// 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_
+
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)
else
{
if(initialValueIsSet)
- initialValueInt = initialValue->getInt();
+ initialValueInt = initialValue->getLong();
if(endValueIsSet)
- endValueInt = endValue->getInt();
+ endValueInt = endValue->getLong();
}
queryAttributeRangeInt(properties, idSet, initialValueIsSet, initialValueInt, endValueIsSet, endValueInt);
#include "JSAddressBookChangeCallbackManager.h"
#include "ContactAsyncCallbackManager.h"
#include "ContactListenerManager.h"
+#include "ContactFilterConverter.h"
+#include <ArgumentValidator.h>
+#include <JSWebAPIError.h>
using namespace std;
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;
};
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 }
};
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());
}
}
- ContactPtr contact = dplEvent->getContact();
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
+ ContactPtr contact = dplEvent->getContact();
JSValueRef result;
Try {
result = converter->toJSValueRef(contact);
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());
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);
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());
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);
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());
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);
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);
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 {
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);
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());
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());
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());
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());
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());
#include "ContactConverter.h"
#include "JSContact.h"
#include "Contact.h"
+#include <ArgumentValidator.h>
+#include <JSWebAPIError.h>
#define FILTER_CLASS_NAME "Contact"
};
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 },
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
// 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;
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
}
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
JSValueRef result;
Try {
result = converter->toJSValueRef(vCard);
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;
}
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,
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;
}
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;
}
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;
}
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;
}
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;
}
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
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,
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
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");
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;
}
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;
}
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
};
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 }
};
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,
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,
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,
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,
#include "ContactConverter.h"
#include "JSPerson.h"
#include "JSContactManagerChangeCallbackManager.h"
+#include "ContactFilterConverter.h"
+#include <ArgumentValidator.h>
+#include <JSWebAPIError.h>
namespace DeviceAPI {
namespace Contact {
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);
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());
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());
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());
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);
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());
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);
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);
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 {
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);
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());
{ 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 }
};
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,
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,
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,
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,
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,
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,
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,
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,
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;
}
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,
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,
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,
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
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;
}
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;
}
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
Try {
if (js2ndParamIsString)
type = converter->toContactWebSiteType(arguments[1]);
+ else
+ type = WEBSITE_TYPE_HOMEPAGE;
} Catch(Exception) {
LogError("2nd argument only support 'HOMEPAGE' or 'BLOG'");
ContactWebSitePtr contactWebSite(new ContactWebSite());
contactWebSite->setUrl(url);
- if(js2ndParamIsString)
- contactWebSite->setType(type);
+ contactWebSite->setType(type);
JSObjectRef jsobject;
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;
}
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
#include "plugin_config.h"
#include "ContactConverter.h"
#include "JSPerson.h"
+#include <ArgumentValidator.h>
+#include <JSWebAPIError.h>
#define FILTER_CLASS_NAME "Person"
};
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 },
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,
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,
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,
{
Try
{
- ContactConverterFactory::ConverterType converter =
- ContactConverterFactory::getConverter(context);
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
PersonPtr person = getPrivData(object);
if(!person->getDisplayContactIdIsSet())
return JSValueMakeNull(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,
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());
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());
}
PersonPtr unlinkedPerson = dplEvent->getPerson();
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
JSValueRef result;
Try
{
{"id", PrimitiveType_String},
{"displayName", PrimitiveType_String},
- {"contactCount", PrimitiveType_Integer},
+ {"contactCount", PrimitiveType_Long},
{"hasPhoneNumber", PrimitiveType_Boolean},
{"hasEmail", PrimitiveType_Boolean},
{"isFavorite", PrimitiveType_Boolean},
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}
)
ContentConverter.cpp
ContentFactory.cpp
ContentFilterValidator.cpp
+ ContentFilterConverter.cpp
ContentFolder.cpp
ContentImage.cpp
ContentManager.cpp
#include <CommonsJavaScript/JSUtils.h>
#include <CommonsJavaScript/Validator.h>
#include <CommonsJavaScript/ScopedJSStringRef.h>
+#include <JSUtil.h>
#include "ContentConverter.h"
#include "JSContent.h"
#include "JSFolder.h"
#include "JSAudioLyrics.h"
-
+using namespace DeviceAPI::Common;
namespace DeviceAPI {
namespace Content {
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;
--- /dev/null
+//
+// 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
+
--- /dev/null
+//
+// 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_
+
{"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},
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;
if(!initialValue->isNullOrUndefined())
{
- if(initialValue->getType() == PrimitiveType_Time)
+ if(initialValue->isType(PrimitiveType_Time))
{
- tm date = initialValue->getDateTm();
+ tm date = *initialValue->getDateTm();
initialValueStr = toDateDbStr(date);
}
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
#include "ContentListener.h"
#include "ContentVideo.h"
#include "ContentImage.h"
+#include "ContentFilterConverter.h"
using namespace DeviceAPI::Common;
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);
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}
)
INCLUDE_DIRECTORIES(
${TOP}/Tizen
- ${TOP}/TimeUtil
${TOP}/Common
${platform_pkgs_datasync_INCLUDE_DIRS}
)
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}
)
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
}
- JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
- return false;
+ return true;
}
}
};
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 },
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
}
- JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
- return false;
+ return true;
}
}
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
}
- JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
- return false;
+ return true;
}
}
};
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 }
};
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}
)
// limitations under the License.
//
-#include <CommonsJavaScript/JSUtils.h>
-
#include <JSWebAPIError.h>
#include <PlatformException.h>
#include <JSUtil.h>
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 {
}
// onpaused
- JSValueRef onpaused = JSUtils::getJSPropertyOrUndefined(globalCtx, object, "onpaused");
+ JSValueRef onpaused = JSUtil::getProperty(globalCtx, object, "onpaused");
if (JSValueIsUndefined(globalCtx, onpaused)) {
onpaused = NULL;
} else {
}
// oncanceled
- JSValueRef oncanceled = JSUtils::getJSPropertyOrUndefined(globalCtx, object, "oncanceled");
+ JSValueRef oncanceled = JSUtil::getProperty(globalCtx, object, "oncanceled");
if (JSValueIsUndefined(globalCtx, oncanceled)) {
oncanceled = NULL;
} else {
}
// oncompleted
- JSValueRef oncompleted = JSUtils::getJSPropertyOrUndefined(globalCtx, object, "oncompleted");
+ JSValueRef oncompleted = JSUtil::getProperty(globalCtx, object, "oncompleted");
if (JSValueIsUndefined(globalCtx, oncompleted)) {
oncompleted = NULL;
} else {
}
// onfailed
- JSValueRef onfailed = JSUtils::getJSPropertyOrUndefined(globalCtx, object, "onfailed");
+ JSValueRef onfailed = JSUtil::getProperty(globalCtx, object, "onfailed");
if (JSValueIsUndefined(globalCtx, onfailed)) {
onfailed = NULL;
} else {
void *user_data;
} DOWNLOAD_EVENT_DATA_T;
-
static gboolean downloadEventCB(void *data) {
int ret;
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));
}
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));
}
} 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());
}
}
} 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());
}
}
} 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());
}
}
} 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) {
} 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;
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);
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}
)
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);
}
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
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
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
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
#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;
* 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
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,
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,
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}
)
JSMessageAttachment.cpp
MessageAsyncCallbackManager.cpp
MessageListenerManager.cpp
+ MessageFilterConverter.cpp
)
SET(SRCS_IMPL
INSTALL(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/messaging
FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE
-)
\ No newline at end of file
+)
{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},
#include "ConversationQueryGenerator.h"
#include "ConversationFilterValidatorFactory.h"
+#include <Commons/Exception.h>
#include <dpl/log/log.h>
#include "log.h"
#include <dpl/log/log.h>
#include "log.h"
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
using namespace DeviceAPI::Tizen;
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;
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();
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);
}
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,
}
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,
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;
}
switch (msgType) {
case SMS:
case MMS:
- return JSValueMakeNull(context);
+ LogError("priority : false");
+ return converter->toJSValueRef(false);
case EMAIL:
{
IEmailPtr email = MessageFactory::convertToEmail(msg);
{
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");
case MMS:
{
IMmsPtr mms = MessageFactory::convertToMms(msg);
+ //JSValueMakeUndefined
return converter->toJSValueRef(mms->getSubject());
}
case EMAIL:
return converter->toJSValueRef(email->getSubject());
}
case SMS:
- return JSValueMakeNull(context);
+ return converter->toJSValueRef("");
default:
LogError("message not support subject");
return JSTizenExceptionFactory::postException(context, exception,
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) {
}
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");
}
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 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");
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);
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));
}
else
{
- return JSValueMakeNull(context);
+ hasAttachmentFlag = false;
}
return converter->toJSValueRef(hasAttachmentFlag);
// 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"
{ "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 }
};
LogDebug("msg->getMessageStatus()=" << msg->getMessageStatus());
if((id.size() == 0) && msg->getMessageStatus() == MESSAGE_STATUS_CREATED)
{
- return JSValueMakeNull(context);
+ return converter->toJSValueRef("");
}
return converter->toJSValueRef(id);
}
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);
}
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,
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,
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,
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;
}
}
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");
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);
}
}
{
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;
}
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);
#include "MessagingErrorMsg.h"
#include "MessageAsyncCallbackManager.h"
+#include "MessageFilterConverter.h"
#include "plugin_config.h"
{
EventQueryMessagesPtr event(new EventQueryMessages());
- FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+ MessageMessagesFilterConverterFactory::ConverterType filterConverter =
+ MessageMessagesFilterConverterFactory::getConverter(context);
JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
{
EventQueryConversationsPtr event(new EventQueryConversations());
- FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+ MessageConversationsFilterConverterFactory::ConverterType filterConverter =
+ MessageConversationsFilterConverterFactory::getConverter(context);
JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
{
EventQueryFoldersPtr event(new EventQueryFolders());
- FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+ MessageFoldersFilterConverterFactory::ConverterType filterConverter =
+ MessageFoldersFilterConverterFactory::getConverter(context);
JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
Try
{
- FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+ MessageMessagesChangeFilterConverterFactory::ConverterType filterConverter =
+ MessageMessagesChangeFilterConverterFactory::getConverter(context);
JSValueRef onSuccessForCbm = NULL;
Try
{
- FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+ MessageConversationsFilterConverterFactory::ConverterType filterConverter =
+ MessageConversationsFilterConverterFactory::getConverter(context);
JSValueRef onSuccessForCbm = NULL;
Try
{
- FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+ MessageFoldersFilterConverterFactory::ConverterType filterConverter =
+ MessageFoldersFilterConverterFactory::getConverter(context);
JSValueRef onSuccessForCbm = NULL;
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();
}
namespace Messaging {
using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
MailSender& MailSender::getInstance()
{
namespace Messaging {
using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
MailSync& MailSync::getInstance()
{
{
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
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
--- /dev/null
+//
+// 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
+
--- /dev/null
+//
+// 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_
+
#include <dpl/log/log.h>
#include "log.h"
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
using namespace DeviceAPI::Tizen;
namespace DeviceAPI {
#include <msg_storage_types.h>
#include <sstream>
#include <time.h>
+#include <iomanip>
#include <dpl/log/log.h>
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");
}
}
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");
}
}
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");
}
}
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);
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
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);
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
recVec = createVectorFromeThreadViewList(threadViewList);
- msg_release_list_struct(&threadViewList);
+ reader.msg_release_list_struct_private(&threadViewList);
LogDebug(">>>");
return recVec;
#include <dpl/log/log.h>
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
using namespace DeviceAPI::Tizen;
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},
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");
}
}
#include <dpl/log/log.h>
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
using namespace DeviceAPI::Tizen;
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}
};
#include <dpl/log/log.h>
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
using namespace DeviceAPI::Tizen;
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},
// 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");
}
}
#include "MsgSqliteWrapper.h"
#include <dpl/log/log.h>
-#include <glib.h>
#define MAX_THREAD_ADDR_LEN 40
#define MAX_THREAD_NAME_LEN 195
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
{
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;
/**
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
{
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++) {
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;
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++) {
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++);
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");
+}
+
+
#include "msg_types.h"
#include "MsgSqliteWrapper.h"
#include "msg_storage_types.h"
+#include "MessageStorageReaderData.h"
#include <string>
+#include <glib.h>
class MessageStorageReader {
private:
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_ */
--- /dev/null
+//\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
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}
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}
)
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");
}
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");
}
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");
}
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");
}
PackageInfoEventCallback::~PackageInfoEventCallback()
{
+ if (m_oninstalled)
+ delete m_oninstalled;
+
+ if (m_onupdated)
+ delete m_onupdated;
+
+ if (m_onuninstalled)
+ delete m_onuninstalled;
}
CallbackUserData* PackageInfoEventCallback::getOnInstalled()
//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()
// 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: {
// 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:
// 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)
JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::UNKNOWN_ERROR, "Platform Error");
errCallback->callSuccessCallback(error);
}
+ //clean-up callback object
+ delete callback;
return;
}
// TODO: how can I handle about uninstallable package???
errCallback->callSuccessCallback(error);
}
+ //clean-up callback object
+ delete callback;
return;
}
JSTizenExceptionFactory::makeErrorObject(globalCtx, JSTizenException::UNKNOWN_ERROR, "Platform Error");
errCallback->callSuccessCallback(error);
}
+ //clean-up callback object
+ delete callback;
return;
}
}
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}
)
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);
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(){
+
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}
)
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
)
+++ /dev/null
-/*
- * 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_ */
-
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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_ */
+++ /dev/null
-/*
- * 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_ */
+++ /dev/null
-/*
- * 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);
-}
-
-}
-}
+++ /dev/null
-/*
- * 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_ */
-/*
- * 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 {
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,
};
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,
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,
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,
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,
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,
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
-/*
- * 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.
*/
static void finalize(JSObjectRef object);
- /**
- * Request push service registration.
- */
static JSValueRef registerService(JSContextRef context,
JSObjectRef object,
JSObjectRef thisObject,
const JSValueRef arguments[],
JSValueRef* exception);
- /**
- * Request push service unregistration.
- */
static JSValueRef unregisterService(JSContextRef context,
JSObjectRef object,
JSObjectRef thisObject,
const JSValueRef arguments[],
JSValueRef* exception);
- /**
- * Connect to the push service and receive notifications.
- */
static JSValueRef connectService(JSContextRef context,
JSObjectRef object,
JSObjectRef thisObject,
const JSValueRef arguments[],
JSValueRef* exception);
- /**
- * Disconnect to the push service and stop receiving notifications.
- */
static JSValueRef disconnectService(JSContextRef context,
JSObjectRef object,
JSObjectRef thisObject,
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__
-/*
- * 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 {
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);
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
-/*
- * 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__
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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)
-
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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.");
-}
-
-}
-}
+++ /dev/null
-/*
- * 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_ */
+++ /dev/null
-/*
- * 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)
-
+++ /dev/null
-/*
- * 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
-/*
- * 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;
}
}
-
-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, ®strationId);
- 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;
}
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;
}
}
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) {
}
}
}
+ }
- 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, ®strationId);
- 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, ®Id);
+ 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
-/*
- * 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__
-/*
- * 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"
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()
{
}
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
-/*
- * 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
+++ /dev/null
-/*
- * 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.");
- }
-}
-
-}
-}
+++ /dev/null
-/*
- * 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_ */
--- /dev/null
+//
+// 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_
-/*
- * 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"
namespace Push {
static FunctionMapping createPushFunctions();
-
-static FunctionMapping PushFunctions =
- createPushFunctions();
+static FunctionMapping PushFunctions = createPushFunctions();
DEFINE_FUNCTION_GETTER(Push, PushFunctions);
// 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
-/*
- * 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)
}
}
-/*
- * 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)
NULL)
PLUGIN_CLASS_MAP_END
-}
-}
-
+} // Push
+} // DeviceAPI
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}
)
}
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");
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");
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();
}
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) {
}
m_lastValue = tmpValue;
}
+
+ JSValueProtect(context, m_lastValue);
}
void EventWatchSysteminfo::setTimer()
ISysteminfoPtr SysteminfoFactory::getSysteminfos()
{
- return ISysteminfoPtr(new Systeminfo());
+ static ISysteminfoPtr obj(new Systeminfo());
+ return obj;
}
SysteminfoFactory& SysteminfoFactory::getInstance()
--- /dev/null
+//
+// 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
--- /dev/null
+//
+// 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_
* @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
* @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
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
AttributeRangeFilter.cpp
SortMode.cpp
IFilterVisitor.cpp
+ IFilterProperties.cpp
FilterValidator.cpp
SimpleCoordinates.cpp
JSAttributeFilter.cpp
${LIBS_COMMON}
${LIBS_WIDGETDB}
${platform_pkgs_tizen_LIBRARIES}
- ${timeutil_impl}
)
SET(SRCS_CONFIG
#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;
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()
//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);
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)
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
#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_
#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()
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;
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();
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;
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
#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;
--- /dev/null
+//
+// 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
--- /dev/null
+//
+// 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_
#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"
#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;
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 }
};
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));
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;
}
if (argumentCount >= 3)
{
- if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2]))
+ if (!JSValueIsUndefined(context, arguments[2]))
js3rdParamIsValue = true;
}
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");
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
#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;
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,
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
#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"
#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;
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 }
};
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));
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;
}
// 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;
}
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");
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
#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;
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,
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
#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;
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));
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);
{
LogDebug("entered");
- bool js2ndParamIsObject = false;
+ bool js2ndParamIsArray = false;
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
Try {
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.");
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");
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
#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;
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,
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