Name: wrt-plugins-tizen
Summary: JavaScript plugins for WebRuntime
-Version: 0.4.59
+Version: 0.4.60
Release: 0
Group: Development/Libraries
License: Apache License, Version 2.0
if (JSIsArrayValue(ctx, arguments[1])) {
std::vector<std::string> daysOfTheWeek = validator.toStringVector(1);
- for (int i = 0; i < daysOfTheWeek.size(); i++ ) {
+ for (size_t i = 0; i < daysOfTheWeek.size(); i++ ) {
if ( (daysOfTheWeek[i]!="SU") && (daysOfTheWeek[i]!="MO") &&
(daysOfTheWeek[i]!="TU") && (daysOfTheWeek[i]!="WE") &&
(daysOfTheWeek[i]!="TH") && (daysOfTheWeek[i]!="FR") &&
callback->invokeCallback("success", deviceObj);
}
}
+ if(result == BT_ERROR_REMOTE_DEVICE_NOT_FOUND) {
+ if(callback) {
+ LoggerE("Not found");
+ JSContextRef context = callback->getContext();
+ NotFoundException error("Not found");
+ callback->invokeCallback("error", JSWebAPIErrorFactory::makeErrorObject(context, error));
+ }
+ }
else {
if(callback) {
JSContextRef context = callback->getContext();
bool mode = validator.toBool(0); // mode
JSObjectRef successCallback = validator.toFunction(1, true); // successCallback
JSObjectRef errorCallback = validator.toFunction(2, true); // errorCallback
- unsigned long timeout = validator.toULong(3, true); // timeout
+ unsigned long timeout = validator.toULong(3, true, 180); // timeout
if(timeout > 65535)
timeout = 180;
TIME_TRACER_ITEM_END(__FUNCTION__, 1);
if(!isCorrectParameter) {
- throw InvalidValuesException("Invalid Value");
+ throw TypeMismatchException("Type Mismatch");
}
return profileHandler;
if (!JSValueIsUndefined(m_context, durationData) && !JSValueIsNull(m_context, durationData)) {
Try {
DurationPropertiesPtr duration = timeUtilConverter.getDuration(durationData);
- long long length = duration->length;
- int unit = duration->unit;
- LoggerD("duration length: "<<length<<", unit "<<unit);
+ LoggerD("duration length: "<<duration->length<<", unit "<<duration->unit);
result->setDuration(duration);
} Catch(Exception) {
}
if (!JSValueIsUndefined(m_context, progressData)) {
- result->setProgress(toInt(progressData));
+ result->setProgress(toUChar(progressData));
}
LoggerD("timezone: "<<result->getTimeZone());
m_recurrence(new EventRecurrenceRule()),
m_status(UNDEFINED_STATUS),
m_alarms(new EventAlarmList()),
+ m_alarmsJSRef(NULL),
m_categories(new StringArray()),
m_categoriesJSRef(NULL),
m_isAllDay(false),
m_uid(UNDEFINED_ID),
m_recurrenceId(UNDEFINED_TIME),
m_attendees(new EventAttendeeList()),
+ m_attendeesJSRef(NULL),
m_isDetached(false),
m_geolocation(new DeviceAPI::Tizen::SimpleCoordinates(UNDEFINED_GEO, UNDEFINED_GEO)),
m_timeZone(DEFAULT_TIMEZONE),
alarmPtr->setDescription(original.getAlarms()->at(i)->getDescription());
m_alarms->push_back(alarmPtr);
}
+ m_alarmsJSRef = NULL;
StringArrayPtr categoriesPtr( new StringArray() );
m_categories = categoriesPtr;
attendeePtr->setContactId(original.getAttendees()->at(i)->getContactId());
m_attendees->push_back(attendeePtr);
}
+ m_attendeesJSRef = NULL;
m_isDetached = original.getIsDetached();
CalendarEvent::~CalendarEvent()
{
+ if(m_alarmsJSRef) {
+ LoggerD("Unprotect JS alarms.");
+ JSValueUnprotect(m_context, m_alarmsJSRef);
+ }
+
if(m_categoriesJSRef) {
LoggerD("Unprotect JS categories.");
JSValueUnprotect(m_context, m_categoriesJSRef);
}
+
+ if(m_attendeesJSRef) {
+ LoggerD("Unprotect JS attendees.");
+ JSValueUnprotect(m_context, m_attendeesJSRef);
+ }
}
int CalendarEvent::getId() const
{
m_alarms = value;
}
+JSObjectRef CalendarEvent::getAlarmsJSRef() const
+{
+ return m_alarmsJSRef;
+}
+void CalendarEvent::setAlarmsJSRef(const JSObjectRef value)
+{
+ m_alarmsJSRef = value;
+}
StringArrayPtr CalendarEvent::getCategories() const
{
{
m_attendees = value;
}
+JSObjectRef CalendarEvent::getAttendeesJSRef() const
+{
+ return m_attendeesJSRef;
+}
+void CalendarEvent::setAttendeesJSRef(const JSObjectRef value)
+{
+ m_attendeesJSRef = value;
+}
bool CalendarEvent::getIsDetached() const
{
EventAlarmListPtr getAlarms() const;
void setAlarms(const EventAlarmListPtr value);
+ JSObjectRef getAlarmsJSRef() const;
+ void setAlarmsJSRef(const JSObjectRef value);
StringArrayPtr getCategories() const;
void setCategories(const StringArrayPtr value);
EventAttendeeListPtr getAttendees() const;
void setAttendees(const EventAttendeeListPtr value);
+ JSObjectRef getAttendeesJSRef() const;
+ void setAttendeesJSRef(const JSObjectRef value);
bool getIsDetached() const;
void setIsDetached(bool value);
EventRecurrenceRulePtr m_recurrence;
EventStatus m_status;
EventAlarmListPtr m_alarms;
+ JSObjectRef m_alarmsJSRef;
StringArrayPtr m_categories;
JSObjectRef m_categoriesJSRef;
bool m_isAllDay;
std::string m_uid; // uid is same with id.
long long int m_recurrenceId;
EventAttendeeListPtr m_attendees;
+ JSObjectRef m_attendeesJSRef;
bool m_isDetached;
DeviceAPI::Tizen::SimpleCoordinatesPtr m_geolocation;
std::string m_timeZone;
EventId::EventId()
{
- m_uid = "";
- m_recurrenceId = "0";
+ m_uid = UNDEFINED_ID;
+ m_recurrenceId = UNDEFINED_ID;
m_calendarType = CalendarEvent::UNDEFINED_TYPE;
}
{
Try
{
- CalendarEventPtr event = getPrivateObject(object);
+ CalendarEventPtr item = getPrivateObject(object);
CalendarConverter converter(context);
- event->setCategories(converter.toStringArray(value));
+ item->setCategories(converter.toStringArray(value));
+
+ if(item->getCategoriesJSRef()) {
+ LoggerI("Replace a JS object for categories.");
+ JSValueUnprotect(item->getContext(), item->getCategoriesJSRef());
+ item->setCategoriesJSRef(converter.toJSObjectRef(value));
+ JSValueProtect(item->getContext(), value);
+ }
+
return true;
}
Catch(Exception)
{
Try
{
- CalendarEventPtr event = getPrivateObject(object);
+ CalendarEventPtr item = getPrivateObject(object);
- JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
- if (NULL == jsResult) {
- ThrowMsg(NullPointerException, "Can not create array object.");
- }
- for( unsigned int i=0; i<event->getAlarms()->size(); i++) {
- if (!JSSetArrayElement(context, jsResult, i, JSCalendarAlarm::createJSCalendarAlarm(context, event->getAlarms()->at(i)))) {
- ThrowMsg(UnknownException, "Can not insert value into array.");
- }
- }
- return jsResult;
+ if(item->getAlarmsJSRef()) {
+ return item->getAlarmsJSRef();
+ } else {
+ LoggerI("Create a JS object for alarms.");
+ JSObjectRef jsAlarms = JSCreateArrayObject(context, 0, NULL);
+ if (NULL == jsAlarms) {
+ ThrowMsg(NullPointerException, "Cannot create an array object.");
+ }
+ for( unsigned int i=0; i<item->getAlarms()->size(); i++) {
+ if (!JSSetArrayElement(context, jsAlarms, i, JSCalendarAlarm::createJSCalendarAlarm(context, item->getAlarms()->at(i)))) {
+ ThrowMsg(UnknownException, "Cannot insert a value into array.");
+ }
+ }
+
+ JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context);
+ CalendarConverter converter(globalContext);
+ item->setAlarmsJSRef(converter.toJSObjectRef(jsAlarms));
+ JSValueProtect(globalContext, jsAlarms);
+ item->setContext(globalContext);
+
+ return jsAlarms;
+ }
}
Catch(Exception)
{
JSValueRef value,
JSValueRef* exception)
{
- CalendarEventPtr event(NULL);
+ CalendarEventPtr item(NULL);
Try
{
- event = getPrivateObject(object);
+ item = getPrivateObject(object);
CalendarConverter converter(context);
EventAlarmListPtr alarms = converter.toVectorOfEventAlarmsFromReference(value);
- event->setAlarms(alarms);
+ item->setAlarms(alarms);
+
+ if(item->getAlarmsJSRef()) {
+ LoggerI("Replace a JS object for alarms.");
+ JSValueUnprotect(item->getContext(), item->getAlarmsJSRef());
+ item->setAlarmsJSRef(converter.toJSObjectRef(value));
+ JSValueProtect(item->getContext(), value);
+ }
+
return true;
}
Catch(Exception)
TimeUtilConverter timeUtilConverter(context);
DurationPropertiesPtr duration = timeUtilConverter.getDuration(value);
- long long length = duration->length;
- int unit = duration->unit;
- if (length < 0) {
- DeviceAPI::Common::JSWebAPIErrorFactory::postException(context, exception, DeviceAPI::Common::JSWebAPIErrorFactory::INVALID_VALUES_ERROR);
- return false;
- }
-
- LoggerD("length: "<<length<< ", unit:" <<unit);
+ LoggerD("length: "<<duration->length<< ", unit:" <<duration->unit);
item->setDuration(duration);
item->setEndTime(UNDEFINED_TIME);
{
Try
{
- CalendarEventPtr event = getPrivateObject(object);
- EventAttendeeListPtr attendees = event->getAttendees();
- if (attendees) {
- JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
- if (NULL == jsResult) {
- ThrowMsg(NullPointerException, "Can not create array object.");
+ CalendarEventPtr item = getPrivateObject(object);
+
+ if(item->getAttendeesJSRef()) {
+ return item->getAttendeesJSRef();
+ } else {
+ LoggerI("Create a JS object for attendees.");
+ JSObjectRef jsAttendees = JSCreateArrayObject(context, 0, NULL);
+ if (NULL == jsAttendees) {
+ ThrowMsg(NullPointerException, "Cannot create an array object.");
}
+ EventAttendeeListPtr attendees = item->getAttendees();
for(unsigned int i=0; i<attendees->size(); i++) {
- if (!JSSetArrayElement(context, jsResult, i, JSCalendarAttendee::createJSCalendarAttendee(context, attendees->at(i)))) {
- ThrowMsg(UnknownException, "Can not insert value into array.");
+ if (!JSSetArrayElement(context, jsAttendees, i, JSCalendarAttendee::createJSCalendarAttendee(context, attendees->at(i)))) {
+ ThrowMsg(UnknownException, "Cannot insert a value into array.");
}
}
- return jsResult;
+
+ JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context);
+ CalendarConverter converter(globalContext);
+ item->setAttendeesJSRef(converter.toJSObjectRef(jsAttendees));
+ JSValueProtect(globalContext, jsAttendees);
+ item->setContext(globalContext);
+
+ return jsAttendees;
}
}
Catch(Exception)
{
Try
{
- CalendarEventPtr event = getPrivateObject(object);
+ CalendarEventPtr item = getPrivateObject(object);
CalendarConverter converter(context);
- event->setAttendees(converter.toVectorOfAttendeesFromReference(value));
+ item->setAttendees(converter.toVectorOfAttendeesFromReference(value));
+
+ if(item->getAttendeesJSRef()) {
+ LoggerI("Replace a JS object for attendees.");
+ JSValueUnprotect(item->getContext(), item->getAttendeesJSRef());
+ item->setAttendeesJSRef(converter.toJSObjectRef(value));
+ JSValueProtect(item->getContext(), value);
+ }
+
return true;
}
Catch(Exception)
}
if (UNDEFINED_TIME==task->getEndTime()) {
- return JSValueMakeUndefined(context);
+ return JSValueMakeNull(context);
} else {
TimeUtilConverter timeConverter(context);
return timeConverter.toJSValueRefTZDate((double)(task->getEndTime()*1000.0), task->getTimeZone());
rrule->setFrequency(converter.toRecurrenceFrequency(frequency));
return true;
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_INTERVAL)) {
- int interval = converter.toInt(value);
+ unsigned short interval = (unsigned short)(converter.toULong(value));
rrule->setInterval(interval);
return true;
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_UNTIL_DATE)) {
return true;*/
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK)) {
rrule->setDaysOfTheWeek(converter.toStringArray(value));
+
+ if(rrule->getDaysOfTheWeekJSRef()) {
+ LoggerI("Replace a JS object for rrule daysOfTheWeek.");
+ JSValueUnprotect(rrule->getContext(), rrule->getDaysOfTheWeekJSRef());
+ rrule->setDaysOfTheWeekJSRef(converter.toJSObjectRef(value));
+ JSValueProtect(rrule->getContext(), value);
+ }
+
return true;
/*} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR)) {
std::vector<int> daysOfTheYear = converter.toVectorOfInts(value);
return true;*/
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_SET_POSITIONS)) {
rrule->setSetPositions(converter.toNumberArray(value));
+
+ if(rrule->getSetPositionsJSRef()) {
+ LoggerI("Replace a JS object for rrule setPositions.");
+ JSValueUnprotect(rrule->getContext(), rrule->getSetPositionsJSRef());
+ rrule->setSetPositionsJSRef(converter.toJSObjectRef(value));
+ JSValueProtect(rrule->getContext(), value);
+ }
+
return true;
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_EXCEPTIONS)) {
rrule->setExceptions(converter.toTZDateArray(value));
+
+ if(rrule->getExceptionsJSRef()) {
+ LoggerI("Replace a JS object for rrule exceptions.");
+ JSValueUnprotect(rrule->getContext(), rrule->getExceptionsJSRef());
+ rrule->setExceptionsJSRef(converter.toJSObjectRef(value));
+ JSValueProtect(rrule->getContext(), value);
+ }
+
return true;
}
}
}
if (UNDEFINED_TIME==task->getCompletedDate()) {
- return JSValueMakeUndefined(context);
+ return JSValueMakeNull(context);
} else {
TimeUtilConverter timeConverter(context);
return timeConverter.toJSValueRefTZDate((double)(task->getCompletedDate()*1000.0), task->getTimeZone());
{
CalendarEventPtr task = getPrivateObject(object);
Converter converter(context);
- int progress = converter.toInt(value);
+ int progress = converter.toUChar(value);
task->setProgress(progress);
return true;
}
NULL, // getPropertyNames,
NULL, // callAsFunction,
NULL, // callAsConstructor,
- hasInstance,
+ NULL, // hasInstance,
NULL, // convertToType,
};
return static_cast<WebAPIError*>(JSObjectGetPrivate(object));
}
+JSObjectRef JSWebAPIError::constructor(JSContextRef context,
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ return JSWebAPIErrorFactory::postException(context, exception,
+ JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR,
+ "Illegal constructor");
+}
+
void JSWebAPIError::initialize(JSContextRef /*context*/, JSObjectRef /*object*/)
{
}
return JSUtil::toJSValueRef(context, result);
}
-bool JSWebAPIError::hasInstance(JSContextRef context,
- JSObjectRef constructor,
- JSValueRef possibleInstance,
- JSValueRef* /*exception*/)
-{
- return JSValueIsObjectOfClass(context, constructor, getClassRef());
-}
-
} // Common
} // DeviceAPI
static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+ static JSObjectRef constructor(JSContextRef context,
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
private:
static JSObjectRef createJSObject(JSContextRef context, WebAPIError* webapiError);
JSStringRef propertyName,
JSValueRef* exception);
- static bool hasInstance(JSContextRef context,
- JSObjectRef constructor,
- JSValueRef possibleInstance,
- JSValueRef* exception);
-
static JSValueRef toString(JSContextRef context,
JSObjectRef object,
JSObjectRef thisObject,
#include <string>
#include <map>
#include "JSUtil.h"
-#include "JSWebAPIError.h"
+#include "JSStringRefWrapper.h"
#include "Logger.h"
namespace DeviceAPI {
#define CLASS_NAME "WebAPIException"
+#define PROPERTY_CODE "code"
+#define PROPERTY_NAME "name"
+#define PROPERTY_TYPE "type"
+#define PROPERTY_MESSAGE "message"
+
#define PROPERTY_INDEX_SIZE_ERR "INDEX_SIZE_ERR"
#define PROPERTY_DOMSTRING_SIZE_ERR "DOMSTRING_SIZE_ERR"
#define PROPERTY_HIERARCHY_REQUEST_ERR "HIERARCHY_REQUEST_ERR"
0,
kJSClassAttributeNone,
CLASS_NAME,
- JSWebAPIError::getClassRef(),
+ 0,
m_properties,
m_function,
initialize,
NULL, // getPropertyNames,
NULL, // callAsFunction,
NULL, // callAsConstructor,
- hasInstance,
+ NULL, // hasInstance,
NULL, // convertToType,
};
};
JSStaticValue JSWebAPIException::m_properties[] = {
+ { PROPERTY_CODE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { PROPERTY_NAME, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { PROPERTY_TYPE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { PROPERTY_MESSAGE, getProperty, NULL, kJSPropertyAttributeReadOnly },
{ PROPERTY_INDEX_SIZE_ERR, getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
{ PROPERTY_DOMSTRING_SIZE_ERR, getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
{ PROPERTY_HIERARCHY_REQUEST_ERR, getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
return static_cast<WebAPIError*>(JSObjectGetPrivate(object));
}
+JSObjectRef JSWebAPIException::constructor(JSContextRef context,
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ return JSWebAPIErrorFactory::postException(context, exception,
+ JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR,
+ "Illegal constructor");
+}
+
+void JSWebAPIException::initializeConstructor(JSContextRef context, JSObjectRef constructor)
+{
+ for(DeviceAPIErrorCodeMap::iterator iter = errorCodes.begin(); iter != errorCodes.end(); iter++)
+ {
+ JSStringRefWrapper name(iter->first);
+ JSValueRef value = JSValueMakeNumber(context, static_cast<double>(iter->second));
+ JSObjectSetProperty(context, constructor, name.get(), value, kJSPropertyAttributeReadOnly, NULL);
+ }
+}
+
void JSWebAPIException::initialize(JSContextRef /*context*/, JSObjectRef /*object*/)
{
}
{
}
+JSValueRef JSWebAPIException::getProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* /*exception*/)
+{
+ WebAPIError* webapiErrObj = getPriv(context, object);
+ if(!webapiErrObj)
+ {
+ LoggerE("Private object is not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ try
+ {
+ std::string propertyNameStr = JSUtil::JSStringToString(context, propertyName);
+
+ if (propertyNameStr == PROPERTY_CODE)
+ {
+ return JSUtil::toJSValueRef(context, static_cast<long>(webapiErrObj->getCode()));
+ }
+ else if (propertyNameStr == PROPERTY_NAME)
+ {
+ return JSUtil::toJSValueRef(context, webapiErrObj->getName());
+ }
+ else if (propertyNameStr == PROPERTY_TYPE)
+ {
+ return JSUtil::toJSValueRef(context, webapiErrObj->getName());
+ }
+ else if (propertyNameStr == PROPERTY_MESSAGE)
+ {
+ return JSUtil::toJSValueRef(context, webapiErrObj->getMessage());
+ }
+ }
+ catch(const BasePlatformException & err)
+ {
+ LoggerE("Exception: " << err.getMessage());
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
JSValueRef JSWebAPIException::getStaticProperty(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
return JSUtil::toJSValueRef(context, result);
}
-bool JSWebAPIException::hasInstance(JSContextRef context,
- JSObjectRef constructor,
- JSValueRef possibleInstance,
- JSValueRef* /*exception*/)
-{
- return JSValueIsObjectOfClass(context, constructor, getClassRef());
-}
-
} // Common
} // DeviceAPI
static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+ static JSObjectRef constructor(JSContextRef context,
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
+ static void initializeConstructor(JSContextRef context, JSObjectRef constructor);
+
private:
static JSObjectRef createJSObject(JSContextRef context, WebAPIError* webapiError);
static void finalize(JSObjectRef object);
- static JSValueRef getStaticProperty(JSContextRef context,
+ static JSValueRef getProperty(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef* exception);
- static bool hasInstance(JSContextRef context,
- JSObjectRef constructor,
- JSValueRef possibleInstance,
+ static JSValueRef getStaticProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
JSValueRef* exception);
static JSValueRef toString(JSContextRef context,
print_log(prio, LOG_TAG, platformLog.str().c_str(), __MODULE__, __func__, __LINE__, ##args); \
} while(0)
-#define LoggerD(fmt, args...) _LOGGER(DLOG_DEBUG, fmt, ##args)
-#define LoggerI(fmt, args...) _LOGGER(DLOG_INFO, fmt, ##args)
-#define LoggerW(fmt, args...) _LOGGER(DLOG_WARN, fmt, ##args)
-#define LoggerE(fmt, args...) _LOGGER(DLOG_ERROR, fmt, ##args)
+#ifdef TIZEN_ENGINEER_MODE
+ #define LoggerD(fmt, args...) _LOGGER(DLOG_DEBUG, fmt, ##args)
+#else
+ #define LoggerD(fmt, args...) do { } while(0)
+#endif
+
+#define LoggerI(fmt, args...) _LOGGER(DLOG_INFO, fmt, ##args)
+#define LoggerW(fmt, args...) _LOGGER(DLOG_WARN, fmt, ##args)
+#define LoggerE(fmt, args...) _LOGGER(DLOG_ERROR, fmt, ##args)
-#ifdef _SECURE_LOG
+
+#ifdef TIZEN_ENGINEER_MODE
#define _SLOGGER(prio, fmt, args...) \
do { \
std::ostringstream platformLog; \
print_log(prio, LOG_TAG, platformLog.str().c_str(), __MODULE__, __func__, __LINE__, ##args); \
} while(0)
#else
-#define _SLOGGER(prio,fmt,args...) (0)
+#define _SLOGGER(prio,fmt,args...) do { } while(0)
#endif
-
-#define SLoggerD(fmt, args...) _SLOGGER(DLOG_DEBUG, fmt, ##args)
-#define SLoggerI(fmt, args...) _SLOGGER(DLOG_INFO, fmt, ##args)
-#define SLoggerE(fmt, args...) _SLOGGER(DLOG_ERROR, fmt, ##args)
+#define SLoggerD(fmt, args...) _SLOGGER(DLOG_DEBUG, fmt, ##args)
+#define SLoggerI(fmt, args...) _SLOGGER(DLOG_INFO, fmt, ##args)
+#define SLoggerE(fmt, args...) _SLOGGER(DLOG_ERROR, fmt, ##args)
#endif // __TIZEN_COMMON_LOGGER_H__
#define TIZEN_SYNC_ACCESS_HANDLER(status, context, exception) \
do { \
switch (status) { \
- case AceSecurityStatus::InternalError: \
- return JSWebAPIErrorFactory::postException(context, exception, \
- JSWebAPIErrorFactory::UNKNOWN_ERROR); \
- break; \
- case AceSecurityStatus::AccessDenied: \
- return JSWebAPIErrorFactory::postException(context, exception, \
- JSWebAPIErrorFactory::SECURITY_ERROR); \
- break; \
- default: \
- break; \
+ case AceSecurityStatus::InternalError: \
+ return JSWebAPIErrorFactory::postException(context, exception, \
+ JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error"); \
+ break; \
+ case AceSecurityStatus::PrivacyDenied: \
+ return JSWebAPIErrorFactory::postException(context, exception, \
+ JSWebAPIErrorFactory::SECURITY_ERROR, "The user blocks an application from calling this method."); \
+ break; \
+ case AceSecurityStatus::AccessDenied: \
+ return JSWebAPIErrorFactory::postException(context, exception, \
+ JSWebAPIErrorFactory::SECURITY_ERROR, "The application does not have the privilege to call this method."); \
+ break; \
+ default: \
+ break; \
} \
} while (0)
switch (status) { \
case AceSecurityStatus::InternalError: \
cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, \
- "SECURITY_ERROR", "internal error")); \
+ JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error")); \
+ return JSValueMakeNull(context); \
+ case AceSecurityStatus::PrivacyDenied: \
+ cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, \
+ JSWebAPIErrorFactory::SECURITY_ERROR, "The user blocks an application from calling this method.")); \
return JSValueMakeNull(context); \
case AceSecurityStatus::AccessDenied: \
cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, \
- JSWebAPIErrorFactory::SECURITY_ERROR, "Security Error")); \
+ JSWebAPIErrorFactory::SECURITY_ERROR, "The application does not have the privilege to call this method.")); \
return JSValueMakeNull(context); \
default: \
break; \
_CONTACTS_SVC_QUERY_FUNC_PREFIX(view_uri, query, filter);
+ if(property_id == _contacts_number.number && match == CONTACTS_MATCH_CONTAINS)
+ property_id = _contacts_number.normalized_number;
+
errorCode = contacts_filter_add_str(filter, property_id, match, match_value);
if(errorCode != CONTACTS_ERROR_NONE)
{
errorCode = contacts_filter_add_int(sub_filter, property_id,
CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, initial_value);
- contacts_filter_add_operator(sub_filter, CONTACTS_FILTER_OPERATOR_AND);
+ errorCode = contacts_filter_add_operator(sub_filter, CONTACTS_FILTER_OPERATOR_AND);
errorCode = contacts_filter_add_int(sub_filter, property_id,
CONTACTS_MATCH_LESS_THAN_OR_EQUAL, end_value);
errorCode = contacts_filter_add_filter(filter, sub_filter);
+ errorCode = contacts_filter_destroy(sub_filter);
}
else if(initial_value_is_set)
{
CONTACTS_MATCH_ENDSWITH, end_value);
errorCode = contacts_filter_add_filter(filter, sub_filter);
+ errorCode = contacts_filter_destroy(sub_filter);
}
else if(initial_value != NULL)
{
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contact->unsetPhotoURI();
- else
+ else*/
contact->setPhotoURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contact->unsetBirthday();
- else
+ else*/
contact->setBirthday(converter->toDateTm(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contact->unsetRingtoneURI();
- else
+ else*/
contact->setRingtoneURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactAddress->unsetCountry();
- else
+ else*/
contactAddress->setCountry(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactAddress->unsetRegion();
- else
+ else*/
contactAddress->setRegion(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactAddress->unsetCity();
- else
+ else*/
contactAddress->setCity(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactAddress->unsetStreetAddress();
- else
+ else*/
contactAddress->setStreetAddress(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactAddress->unsetAdditionalInformation();
- else
+ else*/
contactAddress->setAdditionalInformation(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactAddress->unsetPostalCode();
- else
+ else*/
contactAddress->setPostalCode(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactAddress->unsetLabel();
- else
+ else*/
contactAddress->setLabel(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//anniversary->unsetLabel();
- else
+ else*/
anniversary->setLabel(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactGroup->unsetId();
- else
+ else*/
contactGroup->setId(converter->toString(value));
return true;
}
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactGroup->unsetAddressBookId();
- else
+ else*/
contactGroup->setAddressBookId(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactGroup->unsetName();
- else
+ else*/
contactGroup->setName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactGroup->unsetRingtoneURI();
- else
+ else*/
contactGroup->setRingtoneURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactGroup->unsetRingtoneURI();
- else
+ else*/
contactGroup->setPhotoURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactName->unsetPrefix();
- else
+ else*/
contactName->setPrefix(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::ConverterType converter =
ContactConverterFactory::getConverter(context);
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactName->unsetSuffix();
- else
+ else*/
contactName->setSuffix(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactNamePtr contactName = getPrivData(object);
ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactName->unsetFirstName();
- else
+ else*/
contactName->setFirstName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactName->unsetMiddleName();
- else
+ else*/
contactName->setMiddleName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactName->unsetLastName();
- else
+ else*/
contactName->setLastName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactName->unsetPhoneticFirstName();
- else
+ else*/
contactName->setPhoneticFirstName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactName->unsetPhoneticMiddleName();
- else
+ else*/
contactName->setPhoneticMiddleName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//contactName->unsetPhoneticLastName();
- else
+ else*/
contactName->setPhoneticLastName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//organization->unsetName();
- else
+ else*/
organization->setName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//organization->unsetDepartment();
- else
+ else*/
organization->setDepartment(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//organization->unsetTitle();
- else
+ else*/
organization->setTitle(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//organization->unsetRole();
- else
+ else*/
organization->setRole(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//organization->unsetLogoURI();
- else
+ else*/
organization->setLogoURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//organization->unsetAssistant();
- else
+ else*/
organization->setAssistant(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//organization->unsetLocation();
- else
+ else*/
organization->setLocation(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//organization->unsetDescription();
- else
+ else*/
organization->setDescription(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//organization->unsetPhoneticName();
- else
+ else*/
organization->setPhoneticName(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//organization->unsetType();
- else
+ else*/
organization->setType(converter->toContactOrganizationType(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//organization->unsetLabel();
- else
+ else*/
organization->setLabel(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::getConverter(context);
BasicValidator validator =
BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//webSite->unsetType();
- else
+ else*/
{
ContactWebSiteType type = converter->toContactWebSiteType(converter->toString(value));
webSite->setType(type);
ContactConverterFactory::ConverterType converter =
ContactConverterFactory::getConverter(context);
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//person->unsetPhotoURI();
- else
+ else*/
person->setPhotoURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
ContactConverterFactory::ConverterType converter =
ContactConverterFactory::getConverter(context);
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//person->unsetRingtoneURI();
- else
+ else*/
person->setRingtoneURI(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
PersonPtr person = getPrivData(object);
ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
- if(validator->isNullOrUndefined(value))
+/* if(validator->isNullOrUndefined(value))
return true;//person->unsetDisplayContactId();
- else
+ else*/
person->setDisplayContactId(converter->toString(value));
}
Catch(WrtDeviceApis::Commons::Exception)
else
is_ascending = false;
- contacts_query_set_sort(m_query, property.propertyId, is_ascending);
+ int errorCode = contacts_query_set_sort(m_query, property.propertyId, is_ascending);
+ if(errorCode != CONTACTS_ERROR_NONE)
+ ThrowMsg(PlatformException, "Fail contacts_query_set_sort (ret:" << errorCode << ")");
}
PersonArrayPtr PersonSearchEngine::getResult()
errorCode = contacts_filter_add_int(sub_filter, property.propertyId,
CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, initialValueInt);
- contacts_filter_add_operator(sub_filter, CONTACTS_FILTER_OPERATOR_AND);
+ errorCode = contacts_filter_add_operator(sub_filter, CONTACTS_FILTER_OPERATOR_AND);
errorCode = contacts_filter_add_int(sub_filter, property.propertyId,
CONTACTS_MATCH_LESS_THAN_OR_EQUAL, endValueInt);
if(depth != 0)
{
errorCode = contacts_filter_add_filter(filter, sub_filter);
+ errorCode = contacts_filter_destroy(sub_filter);
}
}
else if(initialValueExists)
if(depth != 0)
{
errorCode = contacts_filter_add_filter(filter, sub_filter);
+ errorCode = contacts_filter_destroy(sub_filter);
}
}
else if(initialValueExists)
bool success = jsFilter->validate(validator);
if(!success){
- eBrowse->setExceptionCode(ExceptionCodes::InvalidArgumentException);
ThrowMsg(InvalidArgumentException, "Invalid attirbutes.");
}
}
}
}
+ catch(const InvalidArgumentException &ex) {
+ LoggerE("Exception: " << ex.DumpToString());
+ eBrowse->setExceptionCode(ExceptionCodes::InvalidArgumentException);
+ eBrowse->setResult(false);
+ }
catch(const Exception &ex)
{
LoggerE("Exception: " << ex.DumpToString());
+ eBrowse->setExceptionCode(ExceptionCodes::UnknownException);
eBrowse->setResult(false);
- return;
}
}
else if(type == INTERSECTION_FILTER)
m_query.append(STR_AND);
else{
- ThrowMsg(PlatformException, "Filter Type is wrong.");
+ ThrowMsg(InvalidArgumentException, "Filter Type is wrong.");
}
}
}
else
{
- ThrowMsg(PlatformException, "Attribute(" << attrName << ") is not supported.");
+ ThrowMsg(InvalidArgumentException, "Attribute(" << attrName << ") is not supported.");
}
}
else if(queryType == QUERY_MEDIA)
}
else
{
- ThrowMsg(PlatformException, "Attribute(" << attrName << ") is not supported.");
+ ThrowMsg(InvalidArgumentException, "Attribute(" << attrName << ") is not supported.");
}
}
matchValueStr = "4";
else
{
- ThrowMsg(PlatformException, "mediaType(" << matchValue->getString() << ") is not supported.");
+ ThrowMsg(InvalidArgumentException, "mediaType(" << matchValue->getString() << ") is not supported.");
}
}
else if(attrName.compare("MEDIA_PATH")==0 || attrName.compare("MEDIA_THUMBNAIL_PATH")==0)
if(matchValue->getDouble() < MIN_LATITUDE ||
matchValue->getDouble() > MAX_LATITUDE)
{
- ThrowMsg(PlatformException, "latitude range is -90 ~ 90");
+ ThrowMsg(InvalidArgumentException, "latitude range is -90 ~ 90");
}
else
{
if(matchValue->getDouble() < MIN_LONGITUDE||
matchValue->getDouble() > MAX_LONGITUDE)
{
- ThrowMsg(PlatformException, "longitude range is -180 ~ 180");
+ ThrowMsg(InvalidArgumentException, "longitude range is -180 ~ 180");
}
else
{
bool IMediacontentManager::setListener( void* user_data)
{
bool ret = false;
-
- if(media_content_set_db_updated_cb(content_notification_cb,user_data) == MEDIA_CONTENT_ERROR_NONE)
+ if(media_content_unset_db_updated_cb() == MEDIA_CONTENT_ERROR_NONE)
{
- ret = true;
+ if(media_content_set_db_updated_cb(content_notification_cb,user_data) == MEDIA_CONTENT_ERROR_NONE)
+ {
+ ret = true;
+ }
}
return ret;
}
JSValueRef value,
JSValueRef* exception)
{
- Try
+ try
{
Converter converter(context);
MediacontentImagePtr objImg = getImageObject(object);
string orientation = converter.toString(value);
+ if (orientation != "NORMAL" && orientation != "FLIP_HORIZONTAL" &&
+ orientation != "ROTATE_180" && orientation != "FLIP_VERTICAL" &&
+ orientation != "TRANSPOSE" && orientation != "ROTATE_90" &&
+ orientation != "TRANSVERSE" && orientation != "ROTATE_270"){
+ throw TypeMismatchException("Invalid orientation type");
+ }
if ((objImg->getImageOrientation()).compare(orientation) !=0 )
{
return true;
}
- Catch(Exception)
+ catch(...)
{
LoggerW("trying to get incorrect value");
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR);
}
return false;
virtual void read(const EventReadTextPtr& event) = 0;
virtual std::string toUri(int widgetId) const = 0;
- virtual bool checkPermission(const IPathPtr& path, const std::string &mode, NodeType type) = 0;
+ virtual bool checkPermission(const std::string mode) = 0;
protected:
INode();
}
if ((AM_READ != mode) && (PERM_READ == privateObject->getObject()->getNode()->getPermissions())) {
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::SECURITY_ERROR, "Permission denied error");
+ cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context,
+ JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "permission denied error"));
+ return JSValueMakeUndefined(context);
}
std::string path = privateObject->getObject()->getNode()->getPath()->getFullPath();
IPathPtr src = Utils::fromVirtualPath(globalContext, converter.toString(reserveArguments[0]));
IPathPtr dest = Utils::fromVirtualPath(globalContext, converter.toString(reserveArguments[1]));
bool overwrite = converter.toBool(reserveArguments[2]);;
-
+/*
+ if ((privateObject->getObject()->getNode()->getPermissions() & PERM_WRITE) == 0) {
+ cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context,
+ JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "permission denied error"));
+ return JSValueMakeUndefined(context);
+ }
+*/
if (NT_DIRECTORY != privateObject->getObject()->getNode()->getType()) {
cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::IO_ERROR, "IO error"));
return JSValueMakeUndefined(context);
reserveArguments[index] = JSValueMakeUndefined(context);
}
- if ((privateObject->getObject()->getNode()->getPermissions() & PERM_WRITE) == 0) {
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::SECURITY_ERROR, "Permission denied error");
- }
-
Converter converter(context);
JSValueRef onSuccess = NULL;
JSValueRef onError = NULL;
cbm->setOnError(onError);
cbm->setObject(thisObject);
+ if ((privateObject->getObject()->getNode()->getPermissions() & PERM_WRITE) == 0) {
+ cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context,
+ JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "permission denied error"));
+ return JSValueMakeUndefined(context);
+ }
+
if (NT_DIRECTORY != privateObject->getObject()->getNode()->getType()) {
cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::IO_ERROR, "io error"));
return JSValueMakeUndefined(context);
if (argc < 1) {
ThrowMsg(InvalidArgumentException, "Invalid path name");
}
+ if ((privateObject->getObject()->getNode()->getPermissions() & PERM_WRITE) == 0) {
+ ThrowMsg(WrtDeviceApis::Commons::SecurityException, "Permission denied error");
+ }
IPathPtr path = converter.toPath(argv[0]);
INodePtr node(privateObject->getObject()->getNode()->createChild(path, NT_DIRECTORY, OPT_RECURSIVE));
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(privateObject->getContext(), getClassRef(), privData);
- } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
+ } catch (const WrtDeviceApis::Commons::SecurityException& ex) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, ex.GetMessage());
+ }
+ catch (const WrtDeviceApis::Commons::PlatformException& ex) {
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::IO_ERROR, ex.GetMessage());
} catch(const WrtDeviceApis::Commons::ConversionException& ex) {
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, ex.GetMessage());
ThrowMsg(InvalidArgumentException, "Invalid path name");
}
+ if ((privateObject->getObject()->getNode()->getPermissions() & PERM_WRITE) == 0) {
+ ThrowMsg(WrtDeviceApis::Commons::SecurityException, "Permission denied error");
+ }
+
IPathPtr path = converter.toPath(argv[0]);
INodePtr node = privateObject->getObject()->getNode()->createChild(path, NT_FILE);
privData->pushParentPermissions(privateObject->getObject()->getNode()->getPermissions());
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(privateObject->getContext(), getClassRef(), privData);
- /*
- IPathPtr path = converter.toPath(argv[0]);
- INodePtr node = privateObject->getObject()->getNode()->createChild(path, NT_FILE);
- return JSUtils::makeObject(privateObject->getContext(), getClassRef(), node);*/
+
+ } catch (const WrtDeviceApis::Commons::SecurityException& ex) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, ex.GetMessage());
} catch (const WrtDeviceApis::Commons::PlatformException& ex) {
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::IO_ERROR, ex.GetMessage());
} catch(const WrtDeviceApis::Commons::ConversionException& ex) {
cbm->setObject(thisObject);
if ((privateObject->getObject()->getNode()->getPermissions() & PERM_WRITE) == 0) {
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::SECURITY_ERROR, "Permission denied error");
+ cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context,
+ JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "permission denied error"));
+ return JSValueMakeUndefined(context);
}
if (privateObject->getObject()->getNode()->getType() != NT_DIRECTORY) {
bool recursive = converter.toBool(reserveArguments[1]);
if (*privateObject->getObject()->getNode()->getPath() != path->getPath()) {
- cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::NOT_FOUND_ERROR, "not found error"));
+ cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::NOT_FOUND_ERROR, "not found error in current directory"));
return JSValueMakeUndefined(context);
}
if(eventResolve->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException)
ThrowMsg(WrtDeviceApis::Commons::NotFoundException, "Not found error");
+ else if(eventResolve->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException){
+ ThrowMsg(WrtDeviceApis::Commons::SecurityException, "Permission denied error");
+ }
else
ThrowMsg(PlatformException, "IO Error");
}
cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, ex.GetMessage()));
} catch(const WrtDeviceApis::Commons::NotFoundException& ex) {
cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::NOT_FOUND_ERROR, ex.GetMessage()));
- } catch(const WrtDeviceApis::Commons::Exception& ex) {
+ } catch(const WrtDeviceApis::Commons::SecurityException& ex) {
+ cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, ex.GetMessage()));
+ }catch(const WrtDeviceApis::Commons::Exception& ex) {
cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, ex.GetMessage()));
}
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
reserveArguments[index] = JSValueMakeUndefined(context);
}
-
- if ((privateObject->getObject()->getNode()->getPermissions() & PERM_WRITE) == 0) {
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::SECURITY_ERROR, "Permission denied error");
- }
-
JSValueRef onSuccess = NULL;
JSValueRef onError = NULL;
cbm->setOnError(onError);
cbm->setObject(thisObject);
+ if ((privateObject->getObject()->getNode()->getPermissions() & PERM_WRITE) == 0) {
+ cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context,
+ JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "permission denied error"));
+ return JSValueMakeUndefined(context);
+ }
+
if (privateObject->getObject()->getNode()->getType() != NT_DIRECTORY) {
cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::IO_ERROR, "IO error"));
return JSValueMakeUndefined(context);
Converter converter(context);
IPathPtr path = Utils::fromVirtualPath(globalContext, converter.toString(reserveArguments[0]));
+ if (*privateObject->getObject()->getNode()->getPath() != path->getPath()) {
+ cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::NOT_FOUND_ERROR, "not found error in current directory"));
+ return JSValueMakeUndefined(context);
+ }
+
+
EventResolvePtr eventResolve(new EventResolve(path));
if (eventResolve->setForSynchronousCall()) {
IManager::getInstance().getNode(eventResolve);
LoggerD("POST IO NOT_FOUND_ERROR");
ThrowMsg(WrtDeviceApis::Commons::NotFoundException, "Not found error");
}
+ if(eventResolve->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException){
+ ThrowMsg(WrtDeviceApis::Commons::SecurityException, "Permission denied error");
+ }
LoggerD("POST IO ERROR");
cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::IO_ERROR, "IO error"));
cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, ex.GetMessage()));
} catch(const WrtDeviceApis::Commons::NotFoundException& ex) {
cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::NOT_FOUND_ERROR, ex.GetMessage()));
+ } catch(const WrtDeviceApis::Commons::SecurityException& ex) {
+ cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, ex.GetMessage()));
} catch(const WrtDeviceApis::Commons::Exception& ex) {
cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, ex.GetMessage()));
}
if (!Utils::isVirtualPath(virtualPath) && !Utils::isUriPath(virtualPath)) {
ThrowMsg(Commons::NotFoundException, "Location not found.");
}
+
+ std::string rootPath;
+ std::size_t found;
+
+ if ((found = virtualPath.find("/")) == std::string::npos) {
+ rootPath = virtualPath;
+ }
+ else {
+ rootPath = virtualPath.substr(0, found);
+ }
+
+ if (virtualPath.find("removable") != std::string::npos) {
+ LoggerD(rootPath << " : " << virtualPath);
+ EventGetStoragePtr getStroageEvent(new EventGetStorage());
+ getStroageEvent->setLabel(rootPath);
+ if (getStroageEvent->setForSynchronousCall()) {
+
+ IManager::getInstance().getStorage(getStroageEvent);
+ StoragePropertiesPtr storage = getStroageEvent->getResult();
+
+ if (storage->getState() != StorageProperties::STATE_MOUNTED &&
+ storage->getState() != StorageProperties::STATE_MOUNTED_READONLY)
+ {
+ ThrowMsg(Commons::NotFoundException, "removable stroage is not available.");
+ }
+ }
+
+ }
path = Utils::fromVirtualPath(globalContext, virtualPath);
perm = converter->toString(reserveArguments[3]);
LoggerD("perms:[" << perm << "]");
if (("r" != perm) && ("rw" != perm) && ("w" != perm) && ("a" != perm)) {
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Invalid permission");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Invalid mode");
} else if ("r" == perm) {
permissions = PERM_READ;
}
}
if (permissions & PERM_WRITE && ((virtualPath == "wgt-package" ) || (virtualPath == "ringtones" ))) {
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::SECURITY_ERROR, "permission denied");
+ cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context,
+ JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "invalid mode, permission denied error"));
+ return JSValueMakeUndefined(context);
}
PermissionsAccessInfo perms(permissions, virtualPath);
{
try {
INodePtr node = Node::resolve(event->getPath());
- if (node->checkPermission(event->getPath(), event->getMode(), node->getType()) == false)
+ if (node->checkPermission(event->getMode()) == false)
{
ThrowMsg(Commons::SecurityException, "Permission Denied Error");
}
}
INodePtr parent;
+
Try {
parent = Node::resolve(IPath::create(dest->getPath()));
+
+ if (parent->checkPermission("rw") == false)
+ {
+ Throw(Commons::SecurityException);
+ }
}
Catch(Commons::NotFoundException)
{
event->setExceptionCode(_rethrown_exception.getCode());
ReThrowMsg(Commons::NotFoundException, "could not find a destination path.");
}
+ Catch(Commons::SecurityException)
+ {
+ event->setExceptionCode(_rethrown_exception.getCode());
+ ReThrowMsg(Commons::SecurityException, "no permission on the destination path");
+ }
Catch (Commons::Exception)
{
event->setExceptionCode(_rethrown_exception.getCode());
ThrowMsg(Commons::PlatformException,
"Destination is same as source.");
}
-
+
+
errno = 0;
struct stat info;
INodePtr parent;
Try {
parent = Node::resolve(IPath::create(dest->getPath()));
+
+ if (parent->checkPermission("rw") == false)
+ {
+ Throw(Commons::SecurityException);
+ }
}
Catch(Commons::NotFoundException)
event->setExceptionCode(_rethrown_exception.getCode());
ReThrowMsg(Commons::NotFoundException, "could not find a destination path.");
}
+ Catch(Commons::SecurityException)
+ {
+ event->setExceptionCode(_rethrown_exception.getCode());
+ ReThrowMsg(Commons::SecurityException, "no permission on the destination path");
+ }
Catch(Commons::Exception)
{
LoggerE("Exception: " << _rethrown_exception.GetMessage());
{
if (!event->checkCancelled()) {
Try {
+
INodePtr node = Node::resolve(event->getPath());
+
+ if (node->checkPermission("rw") == false)
+ {
+ ThrowMsg(Commons::SecurityException, "no permission on the path");
+ }
node->remove(event->getOptions());
}
catch (const Commons::Exception& ex)
void copyElement(const std::string &src,
const std::string &dest,
bool recursive = true) const;
+
private:
static RootList m_rootlist;
namespace Filesystem {
#define MAX_NODE_LENGTH 256
-bool Node::checkPermission(const IPathPtr &path, const std::string &mode, NodeType type)
+bool Node::checkPermission(const std::string mode)
{
- switch (type)
+ switch (m_type)
{
case NT_DIRECTORY:
{
- DIR* dir = opendir(path->getFullPath().c_str());
+ DIR* dir = opendir(m_path->getFullPath().c_str());
if (!dir)
ThrowMsg(Commons::SecurityException, "Node has been deleted from platform.");
time_t now;
time(&now);
ss << now;
- IPathPtr tempFilePath = IPath::create(path->getFullPath());
+ IPathPtr tempFilePath = IPath::create(m_path->getFullPath());
tempFilePath->append(ss.str());
try
{
ThrowMsg(Commons::InvalidArgumentException, "invalid mode");
}
- stream.open(path->getFullPath().c_str(), modeBit);
+ stream.open(m_path->getFullPath().c_str(), modeBit);
if (stream.is_open())
{
public:
- bool checkPermission(const IPathPtr& path, const std::string &mode, NodeType type);
+ bool checkPermission(const std::string mode);
IPathPtr getPath() const;
NodeType getType() const;
int getPermissions() const;
jsException = JSWebAPIErrorFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSWebAPIErrorFactory::NOT_FOUND_ERROR, "NotFoundError");
}
else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
- jsException = JSWebAPIErrorFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSWebAPIErrorFactory::UNKNOWN_ERROR, "PermissionDeniedError");
+ jsException = JSWebAPIErrorFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "PermissionDeniedError");
}
else {
jsException = JSWebAPIErrorFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown error");
}
} else {
JSObjectRef jsException = NULL;
- if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
- jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::SECURITY_ERROR, "Permission denied error");
- } else {
- jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::IO_ERROR, "IO error");
- }
+ jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::IO_ERROR, "IO error");
data->callOnError(jsException);
}
}
if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::NOT_FOUND_ERROR, "NotFoundError");
}
+ else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
+ jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Permission Denied Error");
+ }
else {
jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::IO_ERROR, "IO error");
}
} else {
JSObjectRef jsException = NULL;
if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
- jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::SECURITY_ERROR, "Permission denied error");
+ jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Permission denied error");
}
else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::NOT_FOUND_ERROR, "NotFoundError");
} else {
JSObjectRef jsException = NULL;
if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
- jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::SECURITY_ERROR, "Permission denied error");
+ jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Permission denied error");
}
else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::NOT_FOUND_ERROR, "NotFoundError");
} else {
JSObjectRef jsException = NULL;
if (event->getExceptionCode() ==WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
- jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::SECURITY_ERROR, "Permission denied error");
+ jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Permission denied error");
}
else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::NOT_FOUND_ERROR, "NotFoundError");
} else {
JSObjectRef jsException = NULL;
if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
- jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::SECURITY_ERROR, "Permission denied error");
+ jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Permission denied error");
}
else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::NOT_FOUND_ERROR, "NotFoundError");
}
} else {
JSObjectRef jsException = NULL;
- if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
- jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::SECURITY_ERROR, "Permission denied error");
- }
- else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
+ if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::NOT_FOUND_ERROR, "Not found error");
}
else {
}
} else {
JSObjectRef jsException = NULL;
- if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
- jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::SECURITY_ERROR, "Permission denied error");
- } else {
- jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::IO_ERROR, "IO error");
- }
+ jsException = JSWebAPIErrorFactory::makeErrorObject(data->getContext(), JSWebAPIErrorFactory::IO_ERROR, "IO error");
data->callOnError(jsException);
}
}
#include "CallbackMgr.h"
#include "MsgServiceHandleMgr.h"
#include <Logger.h>
-#include <net_connection.h>
+#include <vconf.h>
extern "C" {
#include <msg.h>
{
LoggerD("updating m_id=" << getIdRef());
msg_error_t err = MSG_SUCCESS;
+ int tempInt = 0;
+
msg_struct_t msg = NULL;
msg_struct_t sendOpt = NULL;
if (err != MSG_SUCCESS)
{
- LoggerE("Get Message Failed!");
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to update message");
+ LoggerE("msg_get_message() Failed!");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to get message for update");
}
if (this->getIdRef().empty()) {
ThrowMsg(WrtDeviceApis::Commons::PlatformException,
"existing msgId is zero, update msg not done");
}
-
+
+ err = msg_get_int_value(msg, MSG_MESSAGE_NETWORK_STATUS_INT, &tempInt);
+ if(err == MSG_SUCCESS)
+ {
+ msg_set_int_value(m_messageData, MSG_MESSAGE_NETWORK_STATUS_INT, tempInt);
+ }
+
+ err = msg_get_int_value(msg, MSG_MESSAGE_FOLDER_ID_INT, &tempInt);
+ if(err == MSG_SUCCESS)
+ {
+ msg_set_int_value(m_messageData, MSG_MESSAGE_FOLDER_ID_INT, tempInt);
+ }
+
update(TRUE);
if (MSG_SUCCESS != msg_update_message(MsgGetCommonHandle(), m_messageData, sendOpt))
{
- LoggerE("Failed to update message");
+ LoggerE("msg_update_message() Failed!");
ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to update message");
}
msg_release_struct(&msg);
bool Mms::getCellularOn()
{
auto cellularOn = true;
- void* connectionHandle;
- if (CONNECTION_ERROR_NONE == connection_create(&connectionHandle)) {
- connection_cellular_state_e cellularState;
- if (CONNECTION_ERROR_NONE == connection_get_cellular_state (connectionHandle,
- &cellularState)) {
- if (CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE == cellularState || CONNECTION_CELLULAR_STATE_FLIGHT_MODE == cellularState) {
- cellularOn = false;
- LoggerW("Cellular State Error" << cellularState);
- }
- } else {
- LoggerE("Can't obtain state of cellular connection");
- }
- connection_destroy(connectionHandle);
- } else {
- LoggerE("Can't obtain state of cellular connection");
+ int tempInt;
+ int tempbool;
+
+ vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &tempInt);
+ vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &tempbool);
+ if(tempInt <= VCONFKEY_TELEPHONY_SVCTYPE_SEARCH || tempbool == TRUE)
+ {
+ LoggerE("VCONFKEY_TELEPHONY_SVCTYPE error " << tempInt);
+ LoggerE("VCONFKEY_TELEPHONY_FLIGHT_MODE error " << tempbool);
+ cellularOn = false;
+ return cellularOn;
+ }
+
+ vconf_get_bool(VCONFKEY_3G_ENABLE, &tempbool);
+ vconf_get_int(VCONFKEY_TELEPHONY_SVC_PS, &tempInt);
+ if(tempbool == FALSE || tempInt != VCONFKEY_TELEPHONY_SVC_PS_ON)
+ {
+ LoggerE("VCONFKEY_3G_ENABLE error " << tempbool);
+ LoggerE("VCONFKEY_TELEPHONY_SVC_PS_ON error " << tempInt);
+ cellularOn = false;
}
return cellularOn;
}
#include "Sms.h"
#include <vconf.h>
-#include <net_connection.h>
#include <Commons/Exception.h>
#include "ReqReceiverMessage.h"
#include "Messaging.h"
bool Sms::getCellularOn()
{
auto cellularOn = true;
- void* connectionHandle;
- if (CONNECTION_ERROR_NONE == connection_create(&connectionHandle)) {
- connection_cellular_state_e cellularState;
- if (CONNECTION_ERROR_NONE == connection_get_cellular_state (connectionHandle,
- &cellularState)) {
- if (CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE == cellularState || CONNECTION_CELLULAR_STATE_FLIGHT_MODE == cellularState) {
- cellularOn = false;
- LoggerW("Cellular State Error" << cellularState);
- }
- } else {
- LoggerE("Can't obtain state of cellular connection");
- }
- connection_destroy(connectionHandle);
- } else {
- LoggerE("Can't obtain state of cellular connection");
+ int tempInt;
+ int tempbool;
+
+ vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &tempInt);
+ vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &tempbool);
+ if(tempInt <= VCONFKEY_TELEPHONY_SVCTYPE_SEARCH || tempbool == TRUE)
+ {
+ LoggerE("VCONFKEY_TELEPHONY_SVCTYPE error " << tempInt);
+ LoggerE("VCONFKEY_TELEPHONY_FLIGHT_MODE error " << tempbool);
+ cellularOn = false;
+ return cellularOn;
+ }
+
+ vconf_get_int(VCONFKEY_TELEPHONY_SVC_CS, &tempInt);
+ if(tempInt != VCONFKEY_TELEPHONY_SVC_CS_ON)
+ {
+ LoggerE("VCONFKEY_TELEPHONY_SVC_CS error " << tempInt);
+ cellularOn = false;
}
return cellularOn;
}
{
LoggerD("updating m_id=" << getIdRef());
msg_error_t err = MSG_SUCCESS;
-
+ int tempInt = 0;
+
msg_struct_t msg = NULL;
msg_struct_t sendOpt = NULL;
if (err != MSG_SUCCESS)
{
- LoggerE("Get Message Failed!");
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to update message");
+ LoggerE("msg_get_message() Failed!");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to get message for update");
}
if (this->getIdRef().empty()) {
ThrowMsg(WrtDeviceApis::Commons::PlatformException,
"existing msgId is zero, update msg not done");
}
-
+
+ err = msg_get_int_value(msg, MSG_MESSAGE_NETWORK_STATUS_INT, &tempInt);
+ if(err == MSG_SUCCESS)
+ {
+ msg_set_int_value(m_messageData, MSG_MESSAGE_NETWORK_STATUS_INT, tempInt);
+ }
+
+ err = msg_get_int_value(msg, MSG_MESSAGE_FOLDER_ID_INT, &tempInt);
+ if(err == MSG_SUCCESS)
+ {
+ msg_set_int_value(m_messageData, MSG_MESSAGE_FOLDER_ID_INT, tempInt);
+ }
+
update(TRUE);
if (MSG_SUCCESS != msg_update_message(MsgGetCommonHandle(), m_messageData, sendOpt))
{
- LoggerE("Failed to update message");
+ LoggerE("msg_update_message() Failed!");
ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to update message");
}
msg_release_struct(&msg);
kJSClassAttributeNone,
"NotificationDetailInfo",
NULL, //ParentClass
- NULL, //StaticValues
+ m_property, //StaticValues
NULL, //StaticFunctions
initialize, //Initialize
finalize, //Finalize
NULL //ConvertToType
};
+JSStaticValue JSNotificationDetailInfo::m_property[] =
+{
+ {NOTIFICATION_DETAIL_INFO_MAIN_TEXT, JSNotificationDetailInfo::getProperty, JSNotificationDetailInfo::setProperty, kJSPropertyAttributeNone },
+ {0, 0, 0, 0}
+};
JSClassRef JSNotificationDetailInfo::m_jsClassRef = JSClassCreate(JSNotificationDetailInfo::getClassInfo());
}
}
+bool JSNotificationDetailInfo::setProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+
+ NotificationDetailInfo *priv = static_cast<NotificationDetailInfo*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ throw TypeMismatchException("NotificationDetailInfo's private object is NULL.");
+ }
+
+ try {
+ std::string property;
+ size_t jsSize = JSStringGetMaximumUTF8CStringSize(propertyName);
+ if (jsSize > 0) {
+ jsSize = jsSize + 1;
+ char* buffer = new char[jsSize];
+ size_t written = JSStringGetUTF8CString(propertyName, buffer, jsSize);
+ if (written > jsSize) {
+ throw InvalidValuesException("Conversion could not be fully performed.");
+ }
+ property = buffer;
+ delete[] buffer;
+ }
+
+ LoggerI("property =" << property);
+
+ if ( property == NOTIFICATION_DETAIL_INFO_MAIN_TEXT)
+ {
+ std::string mainText = JSUtil::JSValueToString(context, value);
+ LoggerI(" mainText = " << mainText);
+ priv->setMainText(mainText);
+
+ //JSUtil::setProperty(context, object, NOTIFICATION_DETAIL_INFO_MAIN_TEXT,
+ //JSUtil::toJSValueRef(context, mainText), kJSPropertyAttributeNone);
+ }
+
+ }
+ catch ( const BasePlatformException& err)
+ {
+ LoggerW(" notification convertion is failed. " << err.getName().c_str() << ":" << err.getMessage().c_str());
+ }
+
+ return false;
+}
+
+JSValueRef JSNotificationDetailInfo::getProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+
+ NotificationDetailInfo *priv = static_cast<NotificationDetailInfo*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ throw TypeMismatchException("NotificationDetailInfo's private object is NULL.");
+ }
+
+ try {
+ std::string property;
+ size_t jsSize = JSStringGetMaximumUTF8CStringSize(propertyName);
+ if (jsSize > 0) {
+ jsSize = jsSize + 1;
+ char* buffer = new char[jsSize];
+ size_t written = JSStringGetUTF8CString(propertyName, buffer, jsSize);
+ if (written > jsSize) {
+ throw InvalidValuesException("Conversion could not be fully performed.");
+ }
+ property = buffer;
+ delete[] buffer;
+ }
+
+ LoggerI("property =" << property);
+ if ( property == NOTIFICATION_DETAIL_INFO_MAIN_TEXT)
+ {
+ std::string main = priv->getMainText();
+
+ return JSUtil::toJSValueRef(context, main);
+ }
+
+ }
+ catch ( const BasePlatformException& err)
+ {
+ LoggerW(" notification convertion is failed. " << err.getName().c_str() << ":" << err.getMessage().c_str());
+ return NULL;
+ }
+
+ return NULL;
+}
+
JSObjectRef JSNotificationDetailInfo::constructor(JSContextRef context,
JSObjectRef constructor,
size_t argumentCount,
static NotificationDetailInfo* getPrivateObject(JSContextRef context, JSObjectRef object);
static void setPrivateObject(JSContextRef context, JSObjectRef object, NotificationDetailInfo *priv);
+ static bool setProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
private:
/**
{
{STATUS_NOTIFICATION_PROGRESS_TYPE, JSStatusNotification::getProperty, JSStatusNotification::setProperty, kJSPropertyAttributeNone },
{STATUS_NOTIFICATION_PROGRESS_VALUE, JSStatusNotification::getProperty, JSStatusNotification::setProperty, kJSPropertyAttributeNone },
+ {STATUS_NOTIFICATION_LIGHT_ONTIME, JSStatusNotification::getProperty, JSStatusNotification::setProperty, kJSPropertyAttributeNone },
+ {STATUS_NOTIFICATION_LIGHT_OFFTIME, JSStatusNotification::getProperty, JSStatusNotification::setProperty, kJSPropertyAttributeNone },
+ {STATUS_NOTIFICATION_VIBRATION, JSStatusNotification::getProperty, JSStatusNotification::setProperty, kJSPropertyAttributeNone },
{0, 0, 0, 0}
};
return true;
}
+ else if ( property == STATUS_NOTIFICATION_LIGHT_ONTIME)
+ {
+ unsigned long onPeriod = JSUtil::JSValueToULong(context, value);
+ LoggerI(" LEDonPeriod = " << onPeriod);
+ priv->setLightOnTime(onPeriod);
+ // JSUtil::setProperty(context, object, STATUS_NOTIFICATION_LIGHT_ONTIME,
+ // JSUtil::toJSValueRef(context, onPeriod), kJSPropertyAttributeNone);
+ }
+ else if ( property == STATUS_NOTIFICATION_LIGHT_OFFTIME)
+ {
+ unsigned long offPeriod = JSUtil::JSValueToULong(context, value);
+ LoggerI(" LEDoffPeriod = " << offPeriod);
+ priv->setLightOffTime(offPeriod);
+
+ // JSUtil::setProperty(context, object, STATUS_NOTIFICATION_LIGHT_OFFTIME,
+ // JSUtil::toJSValueRef(context, offPeriod), kJSPropertyAttributeNone);
+ }
+ else if ( property == STATUS_NOTIFICATION_VIBRATION)
+ {
+ bool vibration = JSUtil::JSValueToBoolean(context, value);
+ LoggerI(" vibration = " << vibration);
+ priv->setDefaultVibration(vibration);
+
+ // JSUtil::setProperty(context, object, STATUS_NOTIFICATION_VIBRATION,
+ // JSUtil::toJSValueRef(context, vibration), kJSPropertyAttributeNone);
+ }
+
}
catch ( const BasePlatformException& err)
{
- LoggerW(" notification convertion is failed. " << err.getName().c_str() << ":" << err.getMessage().c_str());
+ LoggerW(" notification convertion is failed. " << err.getName().c_str() << ":" << err.getMessage().c_str());
}
return JSUtil::toJSValueRef(context, progressVal);
}
}
-
+ else if ( property == STATUS_NOTIFICATION_LIGHT_ONTIME)
+ {
+ unsigned long onTime = priv->getLightOnTime();
+ return JSUtil::toJSValueRef(context, onTime);
+ }
+ else if ( property == STATUS_NOTIFICATION_LIGHT_OFFTIME)
+ {
+ unsigned long offTime = priv->getLightOffTime();
+ return JSUtil::toJSValueRef(context, offTime);
+ }
+ else if ( property == STATUS_NOTIFICATION_VIBRATION)
+ {
+ bool vibration = priv->getDefaultVibration();
+ return JSUtil::toJSValueRef(context, vibration);
+ }
}
catch ( const BasePlatformException& err)
{
*/
static JSClassDefinition m_classInfo;
-
/**
* This member variable contains the initialization values for the
* properties of this class. The values are given according to
}
case PACAKGE_MANAGER_EVENT_STATE_STARTED:
case PACAKGE_MANAGER_EVENT_STATE_PROCESSING: {
- if (callback->getOnProgress()) {
+ if (callback->getOnProgress() && package && package[0]!='\0') {
Converter converter(context);
JSValueRef args[2] = {converter.toJSValueRef(package), converter.toJSValueRef(progress)};
callback->getOnProgress()->callSuccessCallback(2, args);
return "";
}
+
void TimeUtilTools::printDate(Calendar *cal)
{
- UErrorCode ec = U_ZERO_ERROR;
-
if (cal == NULL)
return;
-
+#ifdef TIZEN_ENGINEER_MODE
+ UErrorCode ec = U_ZERO_ERROR;
+
LoggerD("year : " << tolong(cal->get(UCAL_YEAR, ec)));
LoggerD("month : " << tolong(cal->get(UCAL_MONTH, ec)));
LoggerD("day : " << tolong(cal->get(UCAL_DATE, ec)));
LoggerD("zone offset : " << tolong(cal->get(UCAL_ZONE_OFFSET, ec)));
LoggerD("dst offset : " << tolong(cal->get(UCAL_DST_OFFSET, ec)));
LoggerD("is leap month? : " << tolong(cal->get(UCAL_IS_LEAP_MONTH, ec)));
+#endif
}
}
if(argumentCount >= 3)
jsValueMatchValue = arguments[2];
else
- jsValueMatchValue = JSValueMakeUndefined(context);
+ jsValueMatchValue = JSValueMakeNull(context);
AttributeFilterPtr attributeFilter(new AttributeFilter(attributeName, matchFlag, matchValue));
if(argumentCount >= 2)
jsValueInitialValue = arguments[1];
else
- jsValueInitialValue = JSValueMakeUndefined(context);
+ jsValueInitialValue = JSValueMakeNull(context);
endValue = AnyFactory::createAnyEmpty(context);
if(argumentCount >= 3)
jsValueEndValue = arguments[2];
else
- jsValueEndValue = JSValueMakeUndefined(context);
+ jsValueEndValue = JSValueMakeNull(context);
AttributeRangeFilterPtr attributeRangeFilter(new AttributeRangeFilter(attributeName, initialValue, endValue));