Name: wrt-plugins-tizen
Summary: JavaScript plugins for WebRuntime
-Version: 0.4.33
+Version: 0.4.34
Release: 0
Group: Development/Libraries
License: Apache License, Version 2.0
#include <time.h>
#include <JSUtil.h>
+#include <TimeTracer.h>
#include "plugin_config.h"
#include "JSAlarmAbsolute.h"
#include "JSAlarmManager.h"
JSClassRef JSAlarmAbsolute::m_jsClassRef = NULL;
JSClassDefinition JSAlarmAbsolute::m_jsClassInfo = {
- 0,
- kJSClassAttributeNone,
- TIZEN_ALARM_ABSOLUTE_INTERFACE,
- NULL,
- m_property,
- m_function,
- initialize,
- finalize,
- NULL, //hasProperty,
- NULL, //getProperty,
- NULL, //setProperty,
- NULL, //deleteProperty,Geolocation
- NULL, //getPropertyNames,
- NULL,
- NULL, // constructor
- NULL,
- NULL
+ 0,
+ kJSClassAttributeNone,
+ TIZEN_ALARM_ABSOLUTE_INTERFACE,
+ NULL,
+ m_property,
+ m_function,
+ initialize,
+ finalize,
+ NULL, //hasProperty,
+ NULL, //getProperty,
+ NULL, //setProperty,
+ NULL, //deleteProperty,Geolocation
+ NULL, //getPropertyNames,
+ NULL,
+ NULL, // constructor
+ NULL,
+ NULL
};
JSStaticFunction JSAlarmAbsolute::m_function[] = {
- { ALARM_FUNCTION_API_GET_NEXT_SCHEDULED_DATE, JSAlarmAbsolute::getNextScheduledDate, kJSPropertyAttributeNone },
- { 0, 0, 0 }
+ { ALARM_FUNCTION_API_GET_NEXT_SCHEDULED_DATE, JSAlarmAbsolute::getNextScheduledDate, kJSPropertyAttributeNone },
+ { 0, 0, 0 }
};
JSStaticValue JSAlarmAbsolute::m_property[] = {
- { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_ID, getId, NULL, kJSPropertyAttributeReadOnly },
- { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_DATE, getDate, NULL, kJSPropertyAttributeReadOnly },
- { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_PERIOD, getInterval, NULL, kJSPropertyAttributeReadOnly },
- { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_DAYSOFTHEWEEK, getDaysOfTheWeek, NULL, kJSPropertyAttributeReadOnly },
- { 0, 0, 0, 0 }
+ { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_ID, getId, NULL, kJSPropertyAttributeReadOnly },
+ { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_DATE, getDate, NULL, kJSPropertyAttributeReadOnly },
+ { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_PERIOD, getInterval, NULL, kJSPropertyAttributeReadOnly },
+ { TIZEN_ALARM_ABSOLUTE_ATTRIBUTE_DAYSOFTHEWEEK, getDaysOfTheWeek, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
};
const JSClassRef DLL_EXPORT JSAlarmAbsolute::getClassRef()
{
- if (!m_jsClassRef) {
- m_jsClassRef = JSClassCreate(&m_jsClassInfo);
- }
- return m_jsClassRef;
+ if (!m_jsClassRef) {
+ m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+ }
+ return m_jsClassRef;
}
const JSClassDefinition* JSAlarmAbsolute::getClassInfo()
{
- return &m_jsClassInfo;
+ return &m_jsClassInfo;
}
void JSAlarmAbsolute::initialize(JSContextRef context, JSObjectRef object)
{
try {
AlarmAbsolutePtr priv = AlarmAbsolutePtr(new AlarmAbsolute());
- if (!priv) {
- throw TypeMismatchException("Private object is null");
- }
+ if (!priv) {
+ throw TypeMismatchException("Private object is null");
+ }
- ArgumentValidator validator(ctx, argumentCount, arguments);
- time_t date = validator.toTimeT(0);
- struct tm *startDate = localtime(&date);
- mktime(startDate);
-
- priv->setDate(*startDate);
+ ArgumentValidator validator(ctx, argumentCount, arguments);
+ time_t date = validator.toTimeT(0);
+ struct tm *startDate = localtime(&date);
+ mktime(startDate);
+
+ priv->setDate(*startDate);
- if (argumentCount >= 2) {
- if (JSIsArrayValue(ctx, arguments[1])) {
- std::vector<std::string> daysOfTheWeek = validator.toStringVector(1);
+ if (argumentCount >= 2) {
+ if (JSIsArrayValue(ctx, arguments[1])) {
+ std::vector<std::string> daysOfTheWeek = validator.toStringVector(1);
for (int i = 0; i < daysOfTheWeek.size(); i++ ) {
if ( (daysOfTheWeek[i]!="SU") && (daysOfTheWeek[i]!="MO") &&
if(daysOfTheWeek.size() > 0) {
priv->setByDayRecurrence(daysOfTheWeek);
}
- } else {
- long interval = validator.toLong(1);
- if (interval < 0) {
- throw InvalidValuesException("period can not be negative value");
- }
+ } else {
+ long interval = validator.toLong(1);
+ if (interval < 0) {
+ throw InvalidValuesException("period can not be negative value");
+ }
- priv->setInterval(interval);
- }
- }
+ priv->setInterval(interval);
+ }
+ }
- return JSValueToObject(ctx, createJSObject(ctx, priv), exception);
+ return JSValueToObject(ctx, createJSObject(ctx, priv), exception);
} catch (const BasePlatformException& err) {
- return JSWebAPIErrorFactory::postException(ctx, exception, err);
+ return JSWebAPIErrorFactory::postException(ctx, exception, err);
}
}
{
JSAlarmAbsolutePriv *priv = static_cast<JSAlarmAbsolutePriv*>(JSObjectGetPrivate(object));
if (!priv) {
- throw TypeMismatchException("Private object is null");
+ throw TypeMismatchException("Private object is null");
}
AlarmAbsolutePtr result = priv->getObject();
if (!result) {
- throw TypeMismatchException("Private object is null");
+ throw TypeMismatchException("Private object is null");
}
return result;
}
JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData);
if (!priv) {
- throw TypeMismatchException("Private object is null");
+ throw TypeMismatchException("Private object is null");
}
return JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
}
{
JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData);
if (!priv) {
- throw TypeMismatchException("Private object is null");
+ throw TypeMismatchException("Private object is null");
}
return JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
}
JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData);
if (!priv) {
- throw TypeMismatchException("Private object is null");
+ throw TypeMismatchException("Private object is null");
}
return JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
}
JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData);
if (!priv) {
- throw TypeMismatchException("Private object is null");
+ throw TypeMismatchException("Private object is null");
}
return JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
}
JSValueRef JSAlarmAbsolute::getNextScheduledDate( JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception)
{
- try {
- struct tm date;
- Converter converter(ctx);
-
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ try {
+ struct tm date;
+ Converter converter(ctx);
+
AlarmAbsolutePtr privateData = getPrivData(thisObject);
- if (!privateData) {
- throw TypeMismatchException("Private object is null");
- }
-
+ if (!privateData) {
+ throw TypeMismatchException("Private object is null");
+ }
+
if(!privateData->is_registered) {
return JSValueMakeNull(ctx);
}
int id = privateData->getId();
+ TIME_TRACER_ITEM_BEGIN("(getNextScheduledDate)alarm_get_scheduled_date", 0);
int err = alarm_get_scheduled_date(id, &date);
+ TIME_TRACER_ITEM_END("(getNextScheduledDate)alarm_get_scheduled_date", 0);
if(err != ALARM_ERROR_NONE) {
return JSValueMakeNull(ctx);
}
// check wheter the alarm is expired or not
struct tm curr_date;
+ TIME_TRACER_ITEM_BEGIN("(getNextScheduledDate)alarm_get_current_time", 0);
err = alarm_get_current_time(&curr_date);
+ TIME_TRACER_ITEM_END("(getNextScheduledDate)alarm_get_current_time", 0);
if(err != ALARM_ERROR_NONE) {
return JSValueMakeNull(ctx);
}
if (mktime(&date) < mktime(&curr_date)) {
return JSValueMakeNull(ctx);
}
+ TIME_TRACER_ITEM_END(__FUNCTION__, 0);
return converter.toJSValueRef(date);
-
- } catch (const BasePlatformException &err) {
+
+ } catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(ctx, exception, err);
} catch (...) {
DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppSharedURI().");
}
JSValueRef JSAlarmAbsolute::getDate(JSContextRef ctx,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
Converter converter(ctx);
struct tm date;
- try {
+ try {
AlarmAbsolutePtr privateData = getPrivData(object);
- if (!privateData) {
- throw TypeMismatchException("Private object is null");
- }
-
+ if (!privateData) {
+ throw TypeMismatchException("Private object is null");
+ }
+
date = privateData->getDate();
LoggerI("JSAlarmAbsolute Date = " << " Sec : " << date.tm_sec << " Min : "<< date.tm_min
<< " Hour" << date.tm_hour << "Day : " << date.tm_mday << " MON : " << date.tm_mon
JSObjectRef result = JSObjectMakeDate(ctx, 6, args, exception);
return result;
} catch (...) {
- LoggerE("Exception: occured");
+ LoggerE("Exception: occured");
}
- return JSValueMakeUndefined(ctx);
+ return JSValueMakeUndefined(ctx);
}
JSValueRef JSAlarmAbsolute::getId(JSContextRef ctx,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
- try {
+ try {
AlarmAbsolutePtr privateData = getPrivData(object);
- if (!privateData) {
- throw TypeMismatchException("Private object is null");
- }
-
+ if (!privateData) {
+ throw TypeMismatchException("Private object is null");
+ }
+
Converter converter(ctx);
- if (privateData->is_registered) {
+ if (privateData->is_registered) {
std::string strId = converter.toString(privateData->getId());
return converter.toJSValueRef(strId);
} else {
return JSValueMakeNull(ctx);
}
- } catch (...) {
- LoggerE("Exception: occured");
+ } catch (...) {
+ LoggerE("Exception: occured");
}
- return JSValueMakeUndefined(ctx);
+ return JSValueMakeUndefined(ctx);
}
JSValueRef JSAlarmAbsolute::getInterval(JSContextRef ctx,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
- try {
+ try {
AlarmAbsolutePtr privateData = getPrivData(object);
AbsoluteRecurrence::Type alarmType = privateData->getRecurrenceType();
if(alarmType == AbsoluteRecurrence::Interval) {
long interval = privateData->getInterval();
- if (interval == -1 ) {
- return JSValueMakeNull(ctx);
- } else {
- return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, interval);
- }
+ if (interval == -1 ) {
+ return JSValueMakeNull(ctx);
+ } else {
+ return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, interval);
+ }
} else {
return JSValueMakeNull(ctx);
}
} catch (...) {
- LoggerI("Exception: occured");
+ LoggerI("Exception: occured");
}
- return JSValueMakeUndefined(ctx);
+ return JSValueMakeUndefined(ctx);
}
JSValueRef JSAlarmAbsolute::getDaysOfTheWeek(JSContextRef ctx,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
Converter converter(ctx);
try {
AlarmAbsolutePtr privateData = getPrivData(object);
- if (!privateData) {
- throw TypeMismatchException("Private object is null");
- }
+ if (!privateData) {
+ throw TypeMismatchException("Private object is null");
+ }
JSObjectRef jsResult = JSCreateArrayObject(ctx, 0, NULL);
- if (jsResult == NULL) {
- throw UnknownException("Could not create js array object");
+ if (jsResult == NULL) {
+ throw UnknownException("Could not create js array object");
}
-
+
std::vector<std::string> daysOfTheWeek = privateData->getByDayRecurrence();
if(daysOfTheWeek.size() > 0) {
for(size_t i = 0; i<daysOfTheWeek.size(); i++) {
JSValueRef val = converter.toJSValueRef(daysOfTheWeek.at(i));
if(!JSSetArrayElement(ctx, jsResult, i, val)) {
- throw UnknownException("Could not insert value into js array");
+ throw UnknownException("Could not insert value into js array");
}
}
}
return jsResult;
- } catch (...) {
- LoggerI("Exception: occured");
+ } catch (...) {
+ LoggerI("Exception: occured");
}
- return JSValueMakeUndefined(ctx);
+ return JSValueMakeUndefined(ctx);
}
} // Alarm
};
JSStaticValue JSAlarmManager::m_property[] = {
- { TIZEN_ALARM_CONSTANT_PERIOD_MINUTE, getProperty, NULL, kJSPropertyAttributeReadOnly },
- { TIZEN_ALARM_CONSTANT_PERIOD_HOUR, getProperty, NULL, kJSPropertyAttributeReadOnly },
- { TIZEN_ALARM_CONSTANT_PERIOD_DAY, getProperty, NULL, kJSPropertyAttributeReadOnly },
- { TIZEN_ALARM_CONSTANT_PERIOD_WEEK, getProperty, NULL, kJSPropertyAttributeReadOnly },
- { 0, 0, 0, 0 }
+ { TIZEN_ALARM_CONSTANT_PERIOD_MINUTE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { TIZEN_ALARM_CONSTANT_PERIOD_HOUR, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { TIZEN_ALARM_CONSTANT_PERIOD_DAY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { TIZEN_ALARM_CONSTANT_PERIOD_WEEK, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
};
const JSClassRef DLL_EXPORT JSAlarmManager::getClassRef()
JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
- service_h service;
- struct tm startDate;
- int delay = 0;
- int alarm_id;
- std::string applicationId;
- std::string page;
-
- TIME_TRACER_ITEM_BEGIN("(add)ace_check", 0);
- AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_ADD);
- TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
- TIME_TRACER_ITEM_END("(add)ace_check", 0);
-
- try {
- ArgumentValidator validator(ctx, argumentCount, arguments);
- AlarmConverter converter(ctx);
-
- // applicationId
- std::string appId = validator.toString(1);
-
- // alarm
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ service_h service;
+ struct tm startDate;
+ int delay = 0;
+ int alarm_id;
+ std::string applicationId;
+ std::string page;
+
+ TIME_TRACER_ITEM_BEGIN("(add)ace_check", 0);
+ AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_ADD);
+ TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
+ TIME_TRACER_ITEM_END("(add)ace_check", 0);
+
+ try {
+ ArgumentValidator validator(ctx, argumentCount, arguments);
+ AlarmConverter converter(ctx);
+
+ // applicationId
+ std::string appId = validator.toString(1);
+
+ // alarm
JSObjectRef alarmObj = validator.toObject(0);
- if (JSValueIsObjectOfClass(ctx, alarmObj, JSAlarmAbsolute::getClassRef())) {
-
- JSAlarmAbsolutePriv *priv = static_cast<JSAlarmAbsolutePriv*>(JSObjectGetPrivate(alarmObj));
- if (!priv) {
- throw TypeMismatchException("Object is null.");
- }
- AlarmAbsolutePtr alarmPtr = priv->getObject();
- if (!alarmPtr) {
- throw TypeMismatchException("Private object is null.");
- }
-
- startDate = alarmPtr->getDate();
- service = alarmPtr->getService();
- service_set_app_id(service, appId.c_str());
-
- // appControl
- JSObjectRef appControlObj = validator.toObject(2, true);
- if (appControlObj) {
- if(!JSValueIsObjectOfClass(ctx, appControlObj, DeviceAPI::Application::JSApplicationControl::getClassRef())) {
- throw TypeMismatchException("Third parameter is not a ApplicationControl object");
- }
- DeviceAPI::Application::ApplicationConverter applicationConverter(ctx);
- DeviceAPI::Application::ApplicationControlPtr appService = applicationConverter.toApplicationControl(appControlObj);
- if(converter.toAlarmService(service, appService) == false) {
- throw TypeMismatchException("Third parameter is not a ApplicationControl object");
- }
- } else {
- service_set_operation(service, SERVICE_OPERATION_DEFAULT);
- }
-
- AbsoluteRecurrence::Type alarmType = alarmPtr->getRecurrenceType();
-
- int err = ALARM_ERROR_NONE;
- if(alarmType == AbsoluteRecurrence::ByDayValue) {
- int bydayValue = converter.toNativeAlarmValue(alarmPtr->getByDayRecurrence());
- LoggerI("Native bydayValue = " << bydayValue);
- err = alarm_schedule_with_recurrence_week_flag(service, &startDate, bydayValue, &alarm_id);
- } else if(alarmType == AbsoluteRecurrence::Interval) {
- int interval = alarmPtr->getInterval();
- err = alarm_schedule_at_date(service, &startDate, interval, &alarm_id);
- } else {
- err = alarm_schedule_at_date(service, &startDate, 0, &alarm_id);
- }
-
- if(err == ALARM_ERROR_NONE) {
- alarmPtr->setId(alarm_id);
- } else {
- throw UnknownException("Alarm scheduling failed.");
- }
-
- } else if (JSValueIsObjectOfClass(ctx, alarmObj, JSAlarmRelative::getClassRef())) {
-
- JSAlarmRelativePriv *priv = static_cast<JSAlarmRelativePriv*>(JSObjectGetPrivate(alarmObj));
- if (!priv) {
- throw TypeMismatchException("Object is null.");
- }
- AlarmRelativePtr alarmPtr = priv->getObject();
- if (!alarmPtr) {
- throw TypeMismatchException("Private object is null.");
- }
-
- delay = alarmPtr->getDelay();
- long interval = alarmPtr->getPeriod();
- service = alarmPtr->getService();
- service_set_app_id(service, appId.c_str());
-
- // appControl
- JSObjectRef appControlObj = validator.toObject(2, true);
- if (appControlObj) {
- if(!JSValueIsObjectOfClass(ctx, appControlObj, DeviceAPI::Application::JSApplicationControl::getClassRef())) {
- throw TypeMismatchException("Third parameter is not a ApplicationControl object");
- }
- DeviceAPI::Application::ApplicationConverter applicationConverter(ctx);
- DeviceAPI::Application::ApplicationControlPtr appService = applicationConverter.toApplicationControl(appControlObj);
- if(converter.toAlarmService(service, appService) == false) {
- throw TypeMismatchException("Third parameter is not a ApplicationControl object");
- }
- } else {
- service_set_operation(service, SERVICE_OPERATION_DEFAULT);
- }
-
- int err = alarm_schedule_after_delay(service, delay, interval, &alarm_id);
-
- if(err == ALARM_ERROR_NONE) {
- alarmPtr->setId(alarm_id);
- } else {
- throw UnknownException("Alarm scheduling failed.");
- }
-
- } else {
- LoggerE("First parameter is not a Alarm object");
- throw TypeMismatchException("First parameter is not a Alarm object");
- }
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return JSValueMakeUndefined(ctx);
-
- } catch (const BasePlatformException &err) {
+ if (JSValueIsObjectOfClass(ctx, alarmObj, JSAlarmAbsolute::getClassRef())) {
+
+ JSAlarmAbsolutePriv *priv = static_cast<JSAlarmAbsolutePriv*>(JSObjectGetPrivate(alarmObj));
+ if (!priv) {
+ throw TypeMismatchException("Object is null.");
+ }
+ AlarmAbsolutePtr alarmPtr = priv->getObject();
+ if (!alarmPtr) {
+ throw TypeMismatchException("Private object is null.");
+ }
+
+ startDate = alarmPtr->getDate();
+ service = alarmPtr->getService();
+ service_set_app_id(service, appId.c_str());
+
+ // appControl
+ JSObjectRef appControlObj = validator.toObject(2, true);
+ if (appControlObj) {
+ if(!JSValueIsObjectOfClass(ctx, appControlObj, DeviceAPI::Application::JSApplicationControl::getClassRef())) {
+ throw TypeMismatchException("Third parameter is not a ApplicationControl object");
+ }
+ DeviceAPI::Application::ApplicationConverter applicationConverter(ctx);
+ DeviceAPI::Application::ApplicationControlPtr appService = applicationConverter.toApplicationControl(appControlObj);
+ if(converter.toAlarmService(service, appService) == false) {
+ throw TypeMismatchException("Third parameter is not a ApplicationControl object");
+ }
+ } else {
+ service_set_operation(service, SERVICE_OPERATION_DEFAULT);
+ }
+
+ AbsoluteRecurrence::Type alarmType = alarmPtr->getRecurrenceType();
+
+ int err = ALARM_ERROR_NONE;
+ if(alarmType == AbsoluteRecurrence::ByDayValue) {
+ int bydayValue = converter.toNativeAlarmValue(alarmPtr->getByDayRecurrence());
+ LoggerI("Native bydayValue = " << bydayValue);
+ TIME_TRACER_ITEM_BEGIN("(add)alarm_schedule_with_recurrence_week_flag", 0);
+ err = alarm_schedule_with_recurrence_week_flag(service, &startDate, bydayValue, &alarm_id);
+ TIME_TRACER_ITEM_END("(add)alarm_schedule_with_recurrence_week_flag", 0);
+
+ } else if(alarmType == AbsoluteRecurrence::Interval) {
+ int interval = alarmPtr->getInterval();
+ TIME_TRACER_ITEM_BEGIN("(add)alarm_schedule_at_date", 0);
+ err = alarm_schedule_at_date(service, &startDate, interval, &alarm_id);
+ TIME_TRACER_ITEM_END("(add)alarm_schedule_at_date", 0);
+ } else {
+ TIME_TRACER_ITEM_BEGIN("(add)alarm_schedule_at_date", 0);
+ err = alarm_schedule_at_date(service, &startDate, 0, &alarm_id);
+ TIME_TRACER_ITEM_END("(add)alarm_schedule_at_date", 0);
+ }
+
+ if(err == ALARM_ERROR_NONE) {
+ alarmPtr->setId(alarm_id);
+ } else {
+ throw UnknownException("Alarm scheduling failed.");
+ }
+
+ } else if (JSValueIsObjectOfClass(ctx, alarmObj, JSAlarmRelative::getClassRef())) {
+
+ JSAlarmRelativePriv *priv = static_cast<JSAlarmRelativePriv*>(JSObjectGetPrivate(alarmObj));
+ if (!priv) {
+ throw TypeMismatchException("Object is null.");
+ }
+ AlarmRelativePtr alarmPtr = priv->getObject();
+ if (!alarmPtr) {
+ throw TypeMismatchException("Private object is null.");
+ }
+
+ delay = alarmPtr->getDelay();
+ long interval = alarmPtr->getPeriod();
+ service = alarmPtr->getService();
+ service_set_app_id(service, appId.c_str());
+
+ // appControl
+ JSObjectRef appControlObj = validator.toObject(2, true);
+ if (appControlObj) {
+ if(!JSValueIsObjectOfClass(ctx, appControlObj, DeviceAPI::Application::JSApplicationControl::getClassRef())) {
+ throw TypeMismatchException("Third parameter is not a ApplicationControl object");
+ }
+ DeviceAPI::Application::ApplicationConverter applicationConverter(ctx);
+ DeviceAPI::Application::ApplicationControlPtr appService = applicationConverter.toApplicationControl(appControlObj);
+ if(converter.toAlarmService(service, appService) == false) {
+ throw TypeMismatchException("Third parameter is not a ApplicationControl object");
+ }
+ } else {
+ service_set_operation(service, SERVICE_OPERATION_DEFAULT);
+ }
+
+ TIME_TRACER_ITEM_BEGIN("(add)alarm_schedule_after_delay", 0);
+ int err = alarm_schedule_after_delay(service, delay, interval, &alarm_id);
+ TIME_TRACER_ITEM_END("(add)alarm_schedule_after_delay", 0);
+
+ if(err == ALARM_ERROR_NONE) {
+ alarmPtr->setId(alarm_id);
+ } else {
+ throw UnknownException("Alarm scheduling failed.");
+ }
+
+ } else {
+ LoggerE("First parameter is not a Alarm object");
+ throw TypeMismatchException("First parameter is not a Alarm object");
+ }
+ TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ return JSValueMakeUndefined(ctx);
+
+ } catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(ctx, exception, err);
} catch (...) {
DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppSharedURI().");
JSValueRef JSAlarmManager::remove(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN("(add)ace_check", 0);
AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_REMOVE);
TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
+ TIME_TRACER_ITEM_END("(add)ace_check", 0);
- try {
- ArgumentValidator validator(ctx, argumentCount, arguments);
+ try {
+ ArgumentValidator validator(ctx, argumentCount, arguments);
- // id
+ // id
std::string id = validator.toString(0);
-
- int alarmId = 0;
- std::stringstream(id) >> alarmId;
-
- if (alarmId <= 0) {
- throw InvalidValuesException("Invalid ID");
- }
-
- TIME_TRACER_ITEM_BEGIN("(remove)alarm_cancel", 0);
- int ret = alarm_cancel(alarmId);
- TIME_TRACER_ITEM_END("(remove)alarm_cancel", 0);
-
- if (ret != ALARM_ERROR_NONE) {
- throw NotFoundException("Alarm not found");
- }
-
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return JSValueMakeUndefined(ctx);
- } catch (const BasePlatformException &err) {
+
+ int alarmId = 0;
+ std::stringstream(id) >> alarmId;
+
+ if (alarmId <= 0) {
+ throw InvalidValuesException("Invalid ID");
+ }
+
+ TIME_TRACER_ITEM_BEGIN("(remove)alarm_cancel", 0);
+ int ret = alarm_cancel(alarmId);
+ TIME_TRACER_ITEM_END("(remove)alarm_cancel", 0);
+
+ if (ret != ALARM_ERROR_NONE) {
+ throw NotFoundException("Alarm not found");
+ }
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ return JSValueMakeUndefined(ctx);
+ } catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(ctx, exception, err);
} catch (...) {
DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppSharedURI().");
JSValueRef JSAlarmManager::removeAll(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN("(add)ace_check", 0);
AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_REMOVE_ALL);
TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
+ TIME_TRACER_ITEM_END("(add)ace_check", 0);
- TIME_TRACER_ITEM_BEGIN("(removeAll)alarm_cancel_all", 0);
- int returnVal = alarm_cancel_all();
- TIME_TRACER_ITEM_END("(removeAll)alarm_cancel_all", 0);
+ TIME_TRACER_ITEM_BEGIN("(removeAll)alarm_cancel_all", 0);
+ int returnVal = alarm_cancel_all();
+ TIME_TRACER_ITEM_END("(removeAll)alarm_cancel_all", 0);
- if (ALARM_ERROR_NONE != returnVal) {
- LoggerE("Error while removing all alarms: "<< returnVal);
- }
+ if (ALARM_ERROR_NONE != returnVal) {
+ LoggerE("Error while removing all alarms: "<< returnVal);
+ }
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 0);
return JSValueMakeUndefined(ctx);
}
JSValueRef JSAlarmManager::get(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
try {
- service_h service = NULL;
- char* alarmType = NULL;
- JSValueRef result = NULL;
-
+ service_h service = NULL;
+ char* alarmType = NULL;
+ JSValueRef result = NULL;
+
ArgumentValidator validator(ctx, argumentCount, arguments);
- AlarmConverter converter(ctx);
+ AlarmConverter converter(ctx);
// id
std::string id = validator.toString(0);
- int alarmId = 0;
- std::stringstream(id) >> alarmId;
-
- if (alarmId <= 0) {
- LoggerE("Wrong Alarm ID");
- throw InvalidValuesException("Invalid ID");
- }
-
- TIME_TRACER_ITEM_BEGIN("(get)alarm_get_service", 0);
- int ret = alarm_get_service(alarmId, &service);
- TIME_TRACER_ITEM_END("(get)alarm_get_service", 0);
-
- if (ret != ALARM_ERROR_NONE) {
- throw NotFoundException("Alarm not found");
- }
-
- ret = service_get_extra_data(service, ALARM_TYPE_KEY, &alarmType);
- if (ret != SERVICE_ERROR_NONE) {
- LoggerE("Getting data failed: " << ret);
- service_destroy(service);
- throw UnknownException("Unknown error occurred.");
- }
-
- if (strcmp(alarmType, ALARM_TYPE_ABSOLUTE_VALUE) == 0) {
- AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute(service));
-
- if(!converter.toAlarmAbsolutePtr(alarmId, service, privateData)) {
- service_destroy(service);
+ int alarmId = 0;
+ std::stringstream(id) >> alarmId;
+
+ if (alarmId <= 0) {
+ LoggerE("Wrong Alarm ID");
+ throw InvalidValuesException("Invalid ID");
+ }
+
+ TIME_TRACER_ITEM_BEGIN("(get)alarm_get_service", 0);
+ int ret = alarm_get_service(alarmId, &service);
+
+ if (ret != ALARM_ERROR_NONE) {
+ throw NotFoundException("Alarm not found");
+ }
+
+ ret = service_get_extra_data(service, ALARM_TYPE_KEY, &alarmType);
+ if (ret != SERVICE_ERROR_NONE) {
+ LoggerE("Getting data failed: " << ret);
+ service_destroy(service);
+ throw UnknownException("Unknown error occurred.");
+ }
+ TIME_TRACER_ITEM_END("(get)alarm_get_service", 0);
+
+ if (strcmp(alarmType, ALARM_TYPE_ABSOLUTE_VALUE) == 0) {
+ AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute(service));
+
+ if(!converter.toAlarmAbsolutePtr(alarmId, service, privateData)) {
+ service_destroy(service);
throw TypeMismatchException("Alarm not found");
}
- result = JSAlarmAbsolute::createJSObject(ctx, privateData);
+ result = JSAlarmAbsolute::createJSObject(ctx, privateData);
- } else if(strcmp(alarmType, ALARM_TYPE_RELATIVE_VALUE) == 0) {
+ } else if(strcmp(alarmType, ALARM_TYPE_RELATIVE_VALUE) == 0) {
AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative(service));
-
+
if(!converter.toAlarmRelativePtr(alarmId, service, privateData)) {
- service_destroy(service);
+ service_destroy(service);
throw TypeMismatchException("Alarm not found");
}
-
+
result = JSAlarmRelative::createJSObject(ctx, privateData);
- } else {
- service_destroy(service);
- throw UnknownException("Unknown error occurred.");
- }
-
- service_destroy(service);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return result;
+ } else {
+ service_destroy(service);
+ throw UnknownException("Unknown error occurred.");
+ }
+
+ service_destroy(service);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ return result;
} catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(ctx, exception, err);
} catch (...) {
JSValueRef JSAlarmManager::getAll(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
try {
- AlarmConverter converter(ctx);
- std::vector<int> alarmIds;
-
+ AlarmConverter converter(ctx);
+ std::vector<int> alarmIds;
+
+ TIME_TRACER_ITEM_BEGIN("(getAll)alarm_foreach_registered_alarm", 0);
int error = alarm_foreach_registered_alarm(alarm_iterate_callback, &alarmIds);
+ TIME_TRACER_ITEM_END("(getAll)alarm_foreach_registered_alarm", 0);
if (error == ALARM_ERROR_CONNECTION_FAIL) {
LoggerE("Alarm system may not be ready yet.");
alarmIds.clear();
}
JSObjectRef jsResult = JSCreateArrayObject(ctx, 0, NULL);
- if (jsResult == NULL) {
- throw TypeMismatchException("Could not create js array object.");
- }
+ if (jsResult == NULL) {
+ throw TypeMismatchException("Could not create js array object.");
+ }
- for (size_t i = 0 ; i < alarmIds.size(); i++) {
+ for (size_t i = 0 ; i < alarmIds.size(); i++) {
service_h handle = NULL;
char* alarmType = NULL;
-
+
+ TIME_TRACER_ITEM_BEGIN("(getAll)alarm_get_service", 0);
error = alarm_get_service(alarmIds.at(i), &handle);
+ TIME_TRACER_ITEM_END("(getAll)alarm_get_service", 0);
if(error != ALARM_ERROR_NONE) {
LoggerE("Getting service failed: " << error);
throw NotFoundException("Alarm not found");
}
+ TIME_TRACER_ITEM_BEGIN("(getAll)service_get_extra_data", 0);
error = service_get_extra_data(handle, ALARM_TYPE_KEY, &alarmType);
+ TIME_TRACER_ITEM_END("(getAll)service_get_extra_data", 0);
if(error != SERVICE_ERROR_NONE) {
LoggerI("Getting data failed: " << error);
service_destroy(handle);
throw UnknownException("Unknown error occurred.");
}
- JSValueRef obj = NULL;
- if (strcmp(alarmType, ALARM_TYPE_ABSOLUTE_VALUE) == 0) {
- AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute(handle));
+ JSValueRef obj = NULL;
+ if (strcmp(alarmType, ALARM_TYPE_ABSOLUTE_VALUE) == 0) {
+ AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute(handle));
- if(!converter.toAlarmAbsolutePtr(alarmIds.at(i), handle, privateData)) {
- service_destroy(handle);
- throw TypeMismatchException("Absolute alarm conversion failed.");
- }
+ if(!converter.toAlarmAbsolutePtr(alarmIds.at(i), handle, privateData)) {
+ service_destroy(handle);
+ throw TypeMismatchException("Absolute alarm conversion failed.");
+ }
- obj = JSAlarmAbsolute::createJSObject(ctx, privateData);
-
+ obj = JSAlarmAbsolute::createJSObject(ctx, privateData);
+
} else if( !strcmp(alarmType, ALARM_TYPE_RELATIVE_VALUE)) {
AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative(handle));
-
+
if(!converter.toAlarmRelativePtr(alarmIds.at(i), handle, privateData)) {
- service_destroy(handle);
- throw TypeMismatchException("Relative alarm conversion failed.");
+ service_destroy(handle);
+ throw TypeMismatchException("Relative alarm conversion failed.");
}
obj = JSAlarmRelative::createJSObject(ctx, privateData);
} else {
- service_destroy(handle);
- throw UnknownException("Unknown error occurred.");
- }
+ service_destroy(handle);
+ throw UnknownException("Unknown error occurred.");
+ }
service_destroy(handle);
-
- if(!JSSetArrayElement(ctx, jsResult, i, obj)) {
- service_destroy(handle);
- throw UnknownException("JS array creation failed.");
- }
- }
-
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return jsResult;
+
+ if(!JSSetArrayElement(ctx, jsResult, i, obj)) {
+ service_destroy(handle);
+ throw UnknownException("JS array creation failed.");
+ }
+ }
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ return jsResult;
} catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(ctx, exception, err);
} catch (...) {
#include <JSUtil.h>
+#include <TimeTracer.h>
#include <app.h>
#include <time.h>
#include <Export.h>
JSClassRef JSAlarmRelative::m_jsClassRef = NULL;
JSClassDefinition JSAlarmRelative::m_jsClassInfo = {
- 0,
- kJSClassAttributeNone,
- TIZEN_ALARM_RELATIVE_INTERFACE,
- NULL,
- m_property,
- m_function,
- initialize,
- finalize,
- NULL, //hasProperty,
- NULL, //getProperty,
- NULL, //setProperty,
- NULL, //deleteProperty,Geolocation
- NULL, //getPropertyNames,
- NULL,
- NULL, // constructor
- NULL,
- NULL
+ 0,
+ kJSClassAttributeNone,
+ TIZEN_ALARM_RELATIVE_INTERFACE,
+ NULL,
+ m_property,
+ m_function,
+ initialize,
+ finalize,
+ NULL, //hasProperty,
+ NULL, //getProperty,
+ NULL, //setProperty,
+ NULL, //deleteProperty,Geolocation
+ NULL, //getPropertyNames,
+ NULL,
+ NULL, // constructor
+ NULL,
+ NULL
};
JSStaticFunction JSAlarmRelative::m_function[] = {
};
JSStaticValue JSAlarmRelative::m_property[] = {
- { TIZEN_ALARM_RELATIVE_ATTRIBUTE_ID, getId, NULL, kJSPropertyAttributeReadOnly },
- { TIZEN_ALARM_RELATIVE_ATTRIBUTE_DELAY, getDelay, NULL, kJSPropertyAttributeReadOnly },
- { TIZEN_ALARM_RELATIVE_ATTRIBUTE_PERIOD, getPeriod, NULL, kJSPropertyAttributeReadOnly },
- { 0, 0, 0, 0 }
+ { TIZEN_ALARM_RELATIVE_ATTRIBUTE_ID, getId, NULL, kJSPropertyAttributeReadOnly },
+ { TIZEN_ALARM_RELATIVE_ATTRIBUTE_DELAY, getDelay, NULL, kJSPropertyAttributeReadOnly },
+ { TIZEN_ALARM_RELATIVE_ATTRIBUTE_PERIOD, getPeriod, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
};
const JSClassRef DLL_EXPORT JSAlarmRelative::getClassRef()
{
- if (!m_jsClassRef) {
- m_jsClassRef = JSClassCreate(&m_jsClassInfo);
- }
- return m_jsClassRef;
+ if (!m_jsClassRef) {
+ m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+ }
+ return m_jsClassRef;
}
const JSClassDefinition* JSAlarmRelative::getClassInfo()
{
- return &m_jsClassInfo;
+ return &m_jsClassInfo;
}
void JSAlarmRelative::initialize(JSContextRef context, JSObjectRef object)
JSObjectRef DLL_EXPORT JSAlarmRelative::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
- try {
- ArgumentValidator validator(ctx, argumentCount, arguments);
-
- long delay = validator.toLong(0);
- if (delay < 0) {
- throw InvalidValuesException("delay cannot be negative value");
- }
- long period = validator.toLong(1, true, 0);
- if (period < 0) {
- throw InvalidValuesException("period cannot be negative value");
- }
-
- if ((argumentCount > 1) && !JSValueIsNull(ctx, arguments[1])) {
- return JSValueToObject(ctx, createJSObject(ctx, delay, period), exception);
- } else {
- return JSValueToObject(ctx, createJSObject(ctx, delay, -1), exception);
- }
- } catch (const BasePlatformException& err) {
- return JSWebAPIErrorFactory::postException(ctx, exception, err);
+ try {
+ ArgumentValidator validator(ctx, argumentCount, arguments);
+
+ long delay = validator.toLong(0);
+ if (delay < 0) {
+ throw InvalidValuesException("delay cannot be negative value");
+ }
+ long period = validator.toLong(1, true, 0);
+ if (period < 0) {
+ throw InvalidValuesException("period cannot be negative value");
+ }
+
+ if ((argumentCount > 1) && !JSValueIsNull(ctx, arguments[1])) {
+ return JSValueToObject(ctx, createJSObject(ctx, delay, period), exception);
+ } else {
+ return JSValueToObject(ctx, createJSObject(ctx, delay, -1), exception);
+ }
+ } catch (const BasePlatformException& err) {
+ return JSWebAPIErrorFactory::postException(ctx, exception, err);
}
}
{
JSAlarmRelativePriv *priv = static_cast<JSAlarmRelativePriv*>(JSObjectGetPrivate(object));
if (!priv) {
- throw TypeMismatchException("Private object is null");
+ throw TypeMismatchException("Private object is null");
}
AlarmRelativePtr result = priv->getObject();
if (!result) {
- throw TypeMismatchException("Private object is null");
+ throw TypeMismatchException("Private object is null");
}
return result;
}
{
JSAlarmRelativePriv *priv = new JSAlarmRelativePriv(context, privateData);
if (!priv) {
- throw TypeMismatchException("Private object is null");
+ throw TypeMismatchException("Private object is null");
}
return JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
}
JSAlarmRelativePriv *priv = new JSAlarmRelativePriv(context, privateData);
if (!priv) {
- throw TypeMismatchException("Private object is null");
+ throw TypeMismatchException("Private object is null");
}
return JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
}
time_t nextTime;
int id;
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+
try {
AlarmRelativePtr privateData = getPrivData(thisObject);
id = privateData->getId();
+ TIME_TRACER_ITEM_BEGIN("(getRemainingSeconds)alarm_get_scheduled_date", 0);
int err = alarm_get_scheduled_date(id, &date);
+ TIME_TRACER_ITEM_END("(getRemainingSeconds)alarm_get_scheduled_date", 0);
if(err != ALARM_ERROR_NONE)
{
if(err == ALARM_ERROR_INVALID_PARAMETER) {
}
}
+ TIME_TRACER_ITEM_BEGIN("(getRemainingSeconds)alarm_get_current_time", 0);
alarm_get_current_time(¤t);
nextTime = mktime(&date);
currentTime = mktime(¤t);
+ TIME_TRACER_ITEM_END("(getRemainingSeconds)alarm_get_current_time", 0);
long result = nextTime - currentTime;
// It is impossible
throw UnknownException("Unknown exception occurred.");
}
+ TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, result);
- } catch (const BasePlatformException &err) {
+ return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, result);
+ } catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(ctx, exception, err);
} catch (...) {
DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppSharedURI().");
}
JSValueRef JSAlarmRelative::getId(JSContextRef ctx,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
Converter converter(ctx);
try {
AlarmRelativePtr privateData = getPrivData(object);
- if (!privateData) {
- throw TypeMismatchException("Private object is null");
- }
-
- if(privateData->is_registered) {
+ if (!privateData) {
+ throw TypeMismatchException("Private object is null");
+ }
+
+ if(privateData->is_registered) {
std::string strId = converter.toString(privateData->getId());
return converter.toJSValueRef(strId);
} else {
}
JSValueRef JSAlarmRelative::getDelay(JSContextRef ctx,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
long delay;
- try {
+ try {
AlarmRelativePtr privateData = getPrivData(object);
- if (!privateData) {
- throw TypeMismatchException("Private object is null");
- }
-
+ if (!privateData) {
+ throw TypeMismatchException("Private object is null");
+ }
+
delay = privateData->getDelay();
LoggerI("JSAlarmRelative delay = " << delay);
return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, delay);
}
JSValueRef JSAlarmRelative::getPeriod(JSContextRef ctx,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
long period =0;
- try {
+ try {
AlarmRelativePtr privateData = getPrivData(object);
- if (!privateData) {
- throw TypeMismatchException("Private object is null");
- }
-
+ if (!privateData) {
+ throw TypeMismatchException("Private object is null");
+ }
+
period = privateData->getPeriod();
LoggerI("JSAlarmRelative interval = " << period);
if(period == -1) {
return JSValueMakeNull(ctx);
} else {
- return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, period);
+ return DeviceAPI::Common::JSUtil::toJSValueRef(ctx, period);
}
- } catch (const BasePlatformException &err) {
- return JSWebAPIErrorFactory::postException(ctx, exception, err);
- } catch (...) {
- DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
- return JSWebAPIErrorFactory::postException(ctx, exception, err);
- }
+ } catch (const BasePlatformException &err) {
+ return JSWebAPIErrorFactory::postException(ctx, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
+ return JSWebAPIErrorFactory::postException(ctx, exception, err);
+ }
}
} // Alarm
// To get package id from appId
#include <package_manager.h>
+#include <TimeTracer.h>
#include <Logger.h>
return;
}
+ TIME_TRACER_ITEM_BEGIN("(addAppInfoEventListener)pkgmgr_client_new", 0);
m_manager_handle = pkgmgr_client_new(PC_LISTENING);
+ TIME_TRACER_ITEM_END("(addAppInfoEventListener)pkgmgr_client_new", 0);
if (m_manager_handle == NULL) {
ThrowMsg(InvalidArgumentException, "Error while registering listener to app_manager");
}
+ TIME_TRACER_ITEM_BEGIN("(addAppInfoEventListener)pkgmgr_client_listen_status", 0);
pkgmgr_client_listen_status(m_manager_handle, app_list_changed_cb_broker, this);
+ TIME_TRACER_ITEM_END("(addAppInfoEventListener)pkgmgr_client_listen_status", 0);
}
void AppManagerWrapper::unregisterAppListChangedCallbacks()
return;
}
+ TIME_TRACER_ITEM_BEGIN("(removeAppInfoEventListener)pkgmgr_client_free", 0);
pkgmgr_client_free(m_manager_handle);
+ TIME_TRACER_ITEM_END("(removeAppInfoEventListener)pkgmgr_client_free", 0);
m_manager_handle = NULL;
}
void ApplicationController::OnAnswerReceived(const EventApplicationKillPtr &event)
{
ApplicationAsyncAnswerHandler::kill(event);
- TIME_TRACER_ITEM_END("kill(async)", 0);
+ //TIME_TRACER_ITEM_END("kill(async)", 0);
}
void ApplicationController::OnAnswerReceived(const EventApplicationLaunchAppControlPtr &event)
#include "ApplicationControlData.h"
#include "ApplicationControl.h"
#include "ApplicationCert.h"
+#include "Application.h"
#include <Export.h>
-
namespace DeviceAPI {
namespace Application {
class DLL_EXPORT ApplicationConverter : public WrtDeviceApis::CommonsJavaScript::Converter
// To get ppid
#include <unistd.h>
+#include <TimeTracer.h>
+
#include <Logger.h>
namespace DeviceAPI {
}
ApplicationManager::ApplicationManager() :
- m_initialized(false),
- m_app(NULL)
+ m_initialized(false)
{
}
gLaunchAppControlPendingEventMap.eraseKey(this);
}
-void ApplicationManager::getCurrentApplication(const EventApplicationGetCurrAppPtr& event)
-{
- if (m_initialized == false) {
- initialize();
- }
-
- EventRequestReceiver<EventApplicationGetCurrApp>::PostRequest(event);
-}
-
void ApplicationManager::launch(const EventApplicationLaunchPtr& event)
{
if (m_initialized == false) {
EventRequestReceiver<EventApplicationGetAppsContext>::PostRequest(event);
}
-void ApplicationManager::getAppContext(const EventApplicationGetAppContextPtr& event)
-{
- if (m_initialized == false) {
- initialize();
- }
-
- EventRequestReceiver<EventApplicationGetAppContext>::PostRequest(event);
-}
void ApplicationManager::getAppsInfo(const EventApplicationGetAppsInfoPtr& event)
{
EventRequestReceiver<EventApplicationGetAppsInfo>::PostRequest(event);
}
-void ApplicationManager::getAppInfo(const EventApplicationGetAppInfoPtr& event)
-{
- if (m_initialized == false) {
- initialize();
- }
-
- EventRequestReceiver<EventApplicationGetAppInfo>::PostRequest(event);
-}
void ApplicationManager::addAppInfoEventListener(const EventApplicationAddAppInfoEventListenerPtr& event)
{
EventRequestReceiver<EventApplicationRemoveAppInfoEventListener>::PostRequest(event);
}
-void ApplicationManager::getAppCerts(const EventApplicationGetAppCertsPtr& event)
-{
- if (m_initialized == false) {
- initialize();
- }
-
- EventRequestReceiver<EventApplicationGetAppCerts>::PostRequest(event);
-}
-
-
-void ApplicationManager::getAppSharedURI(const EventApplicationGetAppSharedURIPtr& event)
-{
- if (m_initialized == false) {
- initialize();
- }
-
- EventRequestReceiver<EventApplicationGetAppSharedURI>::PostRequest(event);
-}
-
void ApplicationManager::invokeManualAnswerLaunchAppControl(service_h request, service_h reply,
service_result_e result,
}
-void ApplicationManager::OnRequestReceived(const EventApplicationGetCurrAppPtr& event)
+ApplicationPtr ApplicationManager::getCurrentApplication()
{
- if (m_app != NULL) {
- LoggerD("CurrentApplicaton Object is already created.");
- event->setApp(m_app);
- return;
+ std::string appId = get_current_app_id();
+
+ //ApplicationInformationPtr appinfo(new ApplicationInformation(appId));
+ pkgmgrinfo_appinfo_h handle;
+ TIME_TRACER_ITEM_BEGIN("(getCurrentApplication)pkgmgrinfo_appinfo_get_appinfo", 0);
+ int ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &handle);
+ TIME_TRACER_ITEM_END("(getCurrentApplication)pkgmgrinfo_appinfo_get_appinfo", 0);
+ if (ret != PMINFO_R_OK) {
+ LoggerE("Fail to get appInfo");
+ ThrowMsg(UnknownException, "pkgmgrinfo_appinfo_get_appinfo error : unknown error");
}
+ ApplicationInformationPtr appInfo = create_app_info(handle);
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
- Try
+
+ ApplicationPtr app(new Application());
+ app->setAppInfo(appInfo);
+
+ LoggerD("set appinfo to application");
{
- std::string appId = get_current_app_id();
+ //int pid = getpid();
+ int pid = getppid();
+ std::stringstream sstr;
+ sstr << pid;
+ app->setContextId(sstr.str());
+ }
- //ApplicationInformationPtr appinfo(new ApplicationInformation(appId));
- pkgmgrinfo_appinfo_h handle;
- int ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &handle);
- if (ret != PMINFO_R_OK) {
- LoggerE("Fail to get appInfo");
- return;
- }
- ApplicationInformationPtr appInfo = create_app_info(handle);
- pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return app;
+}
- ApplicationPtr app(new Application());
- app->setAppInfo(appInfo);
+ApplicationContextPtr ApplicationManager::getAppContext(const std::string id)
+{
+ int ret = 0;
+
+ std::string contextId = id;
+ int pid;
- LoggerD("set appinfo to application");
+ if (contextId.empty())
+ {
+ //pid = getpid();
+ pid = getppid();
+
+ std::stringstream sstr;
+ sstr << pid;
+ contextId = sstr.str();
+ }
+ else
+ {
+ std::stringstream(contextId) >> pid;
+ if (pid <= 0)
{
- //int pid = getpid();
- int pid = getppid();
- std::stringstream sstr;
- sstr << pid;
- app->setContextId(sstr.str());
+ LoggerE("Given contextId is wrong");
+ ThrowMsg(NotFoundException, "Given contextId is wrong");
}
+ }
+
+ char *app_id = NULL;
- event->setApp(app);
- m_app = app;
+ TIME_TRACER_ITEM_BEGIN("(getAppContext)app_manager_get_app_id", 0);
+ ret = app_manager_get_app_id(pid, &app_id);
+ TIME_TRACER_ITEM_END("(getAppContext)app_manager_get_app_id", 0);
+ if(ret != APP_MANAGER_ERROR_NONE)
+ {
+ if(app_id)
+ free(app_id);
+
+ switch(ret)
+ {
+ case APP_MANAGER_ERROR_NO_SUCH_APP:
+ case APP_MANAGER_ERROR_INVALID_PARAMETER:
+ LoggerE("app_manager_get_app_id error : no such app");
+ ThrowMsg(NotFoundException, "app_manager_get_app_id error : no such app");
+ default:
+ LoggerE("app_manager_get_app_id error (" << ret << ")");
+ ThrowMsg(UnknownException, "app_manager_get_app_id error : unknown error");
+ }
}
- Catch (WrtDeviceApis::Commons::Exception)
+
+ ApplicationContextPtr appContext(new ApplicationContext());
+ appContext->setAppId(app_id);
+ appContext->setContextId(contextId);
+
+ if(app_id)
+ free(app_id);
+
+ return appContext;
+}
+
+
+ApplicationInformationPtr ApplicationManager::getAppInfo(const std::string id)
+{
+ std::string appId = id;
+ // in case of no argument, get application information of current.
+ if (appId.empty())
{
- LoggerE("Error on getAppInfo : " << _rethrown_exception.GetMessage());
- event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+ appId = get_current_app_id();
}
+ pkgmgrinfo_appinfo_h handle;
+ TIME_TRACER_ITEM_BEGIN("(getAppInfo)pkgmgrinfo_appinfo_get_appinfo", 0);
+ int ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &handle);
+ TIME_TRACER_ITEM_END("(getAppInfo)pkgmgrinfo_appinfo_get_appinfo", 0);
+ if (ret != PMINFO_R_OK) {
+ ThrowMsg(NotFoundException, "Can not get appinfo");
+ }
+
+ ApplicationInformationPtr appInfo = create_app_info(handle);
+
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
+ return appInfo;
+}
+
+
+ApplicationCertArrayPtr ApplicationManager::getAppCerts(const std::string id)
+{
+ std::string appId = id;
+
+ // in case of no argument, get application information of current.
+ if (appId.empty())
+ {
+ appId = get_current_app_id();
+ }
+
+ TIME_TRACER_ITEM_BEGIN("(getAppCerts)getPackageByAppId", 0);
+ char* package = getPackageByAppId(appId.c_str());
+ TIME_TRACER_ITEM_END("(getAppCerts)getPackageByAppId", 0);
+ if (package == NULL)
+ {
+ LoggerE("Can not get package");
+ ThrowMsg(NotFoundException, "Can not get package");
+ }
+
+ package_info_h pkg_info;
+ int result = 0;
+
+ TIME_TRACER_ITEM_BEGIN("(getAppCerts)package_manager_get_package_info", 0);
+ result = package_manager_get_package_info(package, &pkg_info);
+ TIME_TRACER_ITEM_END("(getAppCerts)package_manager_get_package_info", 0);
+ if (result != PACKAGE_MANAGER_ERROR_NONE)
+ {
+ ThrowMsg(UnknownException, "Can not get package info");
+ }
+
+ ApplicationCertArrayPtr certArray(new ApplicationCertArray());
+
+ TIME_TRACER_ITEM_BEGIN("(getAppCerts)package_info_foreach_cert_info", 0);
+ result = package_info_foreach_cert_info(pkg_info, package_cert_cb, (void*)certArray.Get());
+ TIME_TRACER_ITEM_END("(getAppCerts)package_info_foreach_cert_info", 0);
+ if (result != PACKAGE_MANAGER_ERROR_NONE)
+ {
+ ThrowMsg(UnknownException, "Can not get package cert info");
+ }
+
+ return certArray;
+}
+
+#define TIZENAPIS_APP_FILE_SCHEME "file://"
+#define TIZENAPIS_APP_SLASH "/"
+#define TIZENAPIS_APP_SHARED "shared"
+
+
+std::string ApplicationManager::getAppSharedURI(const std::string id)
+{
+ std::string appId;
+
+ if (id.empty()) {
+ appId = get_current_app_id();
+ } else {
+ appId = id;
+ }
+
+ app_info_h handle;
+ char* pkg_name = NULL;
+ TIME_TRACER_ITEM_BEGIN("(getAppSharedURI)app_manager_get_app_info", 0);
+ int ret = app_manager_get_app_info(appId.c_str(), &handle);
+ TIME_TRACER_ITEM_END("(getAppSharedURI)app_manager_get_app_info", 0);
+ if (ret != APP_ERROR_NONE) {
+ LoggerD("Fail to get appinfo");
+ //throw NotFoundException("Fail to get appinfo");
+ ThrowMsg(NotFoundException, "Fail to get appinfo");
+ }
+
+ TIME_TRACER_ITEM_BEGIN("(getAppSharedURI)app_info_get_package", 0);
+ ret = app_info_get_package(handle, &pkg_name);
+ TIME_TRACER_ITEM_END("(getAppSharedURI)app_info_get_package", 0);
+ if ((ret != APP_ERROR_NONE) || (pkg_name == NULL)) {
+ LoggerD("Fail to get pkg_name");
+ //throw NotFoundException("Fail to get pkg_name");
+ ThrowMsg(NotFoundException, "Fail to get pkg_name");
+ }
+
+ app_info_destroy(handle);
+
+ pkgmgrinfo_pkginfo_h pkginfo_h;
+ char* root_path = NULL;
+
+ TIME_TRACER_ITEM_BEGIN("(getAppSharedURI)pkgmgrinfo_pkginfo_get_pkginfo", 0);
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &pkginfo_h);
+ TIME_TRACER_ITEM_END("(getAppSharedURI)pkgmgrinfo_pkginfo_get_pkginfo", 0);
+ if (ret != PMINFO_R_OK) {
+ free(pkg_name);
+ //throw UnknownException("Fail to get pkginfo");
+ ThrowMsg(UnknownException, "Fail to get pkginfo");
+ }
+
+ TIME_TRACER_ITEM_BEGIN("(getAppSharedURI)pkgmgrinfo_pkginfo_get_root_path", 0);
+ ret = pkgmgrinfo_pkginfo_get_root_path(pkginfo_h, &root_path);
+ TIME_TRACER_ITEM_END("(getAppSharedURI)pkgmgrinfo_pkginfo_get_root_path", 0);
+ if ((ret != PMINFO_R_OK) || (root_path == NULL)) {
+ LoggerE("Fail to get root path");
+ free(pkg_name);
+ //throw UnknownException("Fail to get rotpath");
+ ThrowMsg(UnknownException, "Fail to get rotpath");
+ }
+
+ std::string sharedURI = TIZENAPIS_APP_FILE_SCHEME + std::string(root_path) + TIZENAPIS_APP_SLASH + TIZENAPIS_APP_SHARED;
+ free(pkg_name);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo_h);
+
+ return sharedURI;
}
}
}
-void ApplicationManager::OnRequestReceived(const EventApplicationGetAppContextPtr& event)
-{
- Try
- {
- int ret = 0;
-
- std::string contextId = event->getAppContextId();
- int pid;
-
- if (contextId.empty())
- {
- //pid = getpid();
- pid = getppid();
-
- std::stringstream sstr;
- sstr << pid;
- contextId = sstr.str();
- }
- else
- {
- std::stringstream(contextId) >> pid;
- if (pid <= 0)
- {
- LoggerE("Given contextId is wrong");
- event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
- return;
- }
- }
- char *app_id = NULL;
-
- ret = app_manager_get_app_id(pid, &app_id);
- if(ret != APP_MANAGER_ERROR_NONE)
- {
- switch(ret)
- {
- case APP_MANAGER_ERROR_NO_SUCH_APP:
- case APP_MANAGER_ERROR_INVALID_PARAMETER:
- LoggerE("app_manager_get_app_id error : no such app");
- event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
- break;
- default:
- LoggerE("app_manager_get_app_id error (" << ret << ")");
- event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
- break;
- }
-
- if(app_id)
- free(app_id);
-
- return;
- }
-
- ApplicationContextPtr appContext(new ApplicationContext());
- appContext->setAppId(app_id);
- appContext->setContextId(contextId);
-
- event->setAppContext(appContext);
-
- if(app_id)
- free(app_id);
- }
- Catch (WrtDeviceApis::Commons::Exception)
- {
- LoggerE("Error on getAppContext : " << _rethrown_exception.GetMessage());
- event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
- }
-}
void ApplicationManager::OnRequestReceived(const EventApplicationGetAppsInfoPtr& event)
{
}
}
-void ApplicationManager::OnRequestReceived(const EventApplicationGetAppInfoPtr& event)
-{
- Try
- {
- std::string appId = event->getAppId();
- // in case of no argument, get application information of current.
- if (appId.empty())
- {
- appId = get_current_app_id();
- }
-
- pkgmgrinfo_appinfo_h handle;
- int ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &handle);
- if (ret != PMINFO_R_OK) {
- event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
- return;
- }
-
- ApplicationInformationPtr appInfo = create_app_info(handle);
- event->setAppInfo(appInfo);
- pkgmgrinfo_appinfo_destroy_appinfo(handle);
- }
- Catch (WrtDeviceApis::Commons::Exception)
- {
- LoggerE("Error on getAppInfo : " << _rethrown_exception.GetMessage());
- event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
- }
-}
void ApplicationManager::OnRequestReceived(const EventApplicationAddAppInfoEventListenerPtr& event)
{
}
-void ApplicationManager::OnRequestReceived(const EventApplicationGetAppCertsPtr& event)
-{
- Try
- {
- std::string appId = event->getAppId();
-
- // in case of no argument, get application information of current.
- if (appId.empty())
- {
- appId = get_current_app_id();
- }
-
- char* package = getPackageByAppId(appId.c_str());
- if (package == NULL)
- {
- LoggerE("Can not get package");
- event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
- return;
- }
-
- package_info_h pkg_info;
- int result = 0;
-
- result = package_manager_get_package_info(package, &pkg_info);
- if (result != PACKAGE_MANAGER_ERROR_NONE)
- {
- event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
- return;
- }
-
- ApplicationCertArrayPtr certArray(new ApplicationCertArray());
-
- result = package_info_foreach_cert_info(pkg_info, package_cert_cb, (void*)certArray.Get());
- if (result != PACKAGE_MANAGER_ERROR_NONE)
- {
- event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
- return;
- }
-
- event->setAppCerts(certArray);
- }
- Catch (WrtDeviceApis::Commons::Exception)
- {
- LoggerE("Error on getAppInfo : " << _rethrown_exception.GetMessage());
- event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
- }
-}
-
-#define TIZENAPIS_APP_FILE_SCHEME "file://"
-#define TIZENAPIS_APP_SLASH "/"
-#define TIZENAPIS_APP_SHARED "shared"
-
-void ApplicationManager::OnRequestReceived(const EventApplicationGetAppSharedURIPtr& event)
-{
- std::string id = event->getAppId();
- std::string appId;
-
- if (id.empty()) {
- appId = get_current_app_id();
- } else {
- appId = id;
- }
-
- app_info_h handle;
- char* pkg_name = NULL;
- int ret = app_manager_get_app_info(appId.c_str(), &handle);
- if (ret != APP_ERROR_NONE) {
- LoggerD("Fail to get appinfo");
- event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
- return;
- }
-
- ret = app_info_get_package(handle, &pkg_name);
- if ((ret != APP_ERROR_NONE) || (pkg_name == NULL)) {
- LoggerD("Fail to get pkg_name");
- event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
- return;
- }
-
- app_info_destroy(handle);
-
- pkgmgrinfo_pkginfo_h pkginfo_h;
- char* root_path = NULL;
-
- ret = pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &pkginfo_h);
- if (ret != PMINFO_R_OK) {
- free(pkg_name);
- event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
- return;
- }
-
- ret = pkgmgrinfo_pkginfo_get_root_path(pkginfo_h, &root_path);
- if ((ret != PMINFO_R_OK) || (root_path == NULL)) {
- LoggerE("Fail to get root path");
- free(pkg_name);
- event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
- return;
- }
-
- std::string sharedURI = TIZENAPIS_APP_FILE_SCHEME + std::string(root_path) + TIZENAPIS_APP_SLASH + TIZENAPIS_APP_SHARED;
- free(pkg_name);
-
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo_h);
-
- event->setSharedURI(sharedURI);
-}
-
-
void ApplicationManager::onAppManagerEventInstalled(const char *appId)
{
#include "IApplicationManager.h"
#include "ApplicationFactory.h"
+#include "Application.h"
+#include "ApplicationContext.h"
+#include "ApplicationInformation.h"
+#include "ApplicationCert.h"
+
//#include <app_manager.h>
#include <app_service.h>
public:
ApplicationManager();
virtual ~ApplicationManager();
- virtual void getCurrentApplication(const EventApplicationGetCurrAppPtr& event);
virtual void launch(const EventApplicationLaunchPtr& event);
virtual void kill(const EventApplicationKillPtr& event);
virtual void launchAppControl(const EventApplicationLaunchAppControlPtr& event);
virtual void findAppControl(const EventApplicationFindAppControlPtr& event);
virtual void getAppsContext(const EventApplicationGetAppsContextPtr& event);
- virtual void getAppContext(const EventApplicationGetAppContextPtr& event);
virtual void getAppsInfo(const EventApplicationGetAppsInfoPtr& event);
- virtual void getAppInfo(const EventApplicationGetAppInfoPtr& event);
virtual void addAppInfoEventListener(const EventApplicationAddAppInfoEventListenerPtr& event);
virtual void removeAppInfoEventListener(const EventApplicationRemoveAppInfoEventListenerPtr& event);
- virtual void getAppCerts(const EventApplicationGetAppCertsPtr& event);
- virtual void getAppSharedURI(const EventApplicationGetAppSharedURIPtr& event);
void invokeManualAnswerLaunchAppControl(service_h request, service_h reply, service_result_e result,
EventApplicationLaunchAppControlReplyPtr &event);
- //void InstalledApplicationChanged(app_manger_event_type_e event_type,const char *package);
void invokeManualAnswerKill(int pid);
static bool service_extra_data_callback(service_h service, const char *key, void* user_data);
+ static ApplicationPtr getCurrentApplication();
+ static ApplicationContextPtr getAppContext(const std::string id);
+ static ApplicationInformationPtr getAppInfo(const std::string id);
+ static ApplicationCertArrayPtr getAppCerts(const std::string id);
+ static std::string getAppSharedURI(const std::string appId);
+
protected:
- virtual void OnRequestReceived(const EventApplicationGetCurrAppPtr& event);
virtual void OnRequestReceived(const EventApplicationLaunchPtr& event);
virtual void OnRequestReceived(const EventApplicationKillPtr& event);
virtual void OnRequestReceived(const EventApplicationLaunchAppControlPtr& event);
virtual void OnRequestReceived(const EventApplicationLaunchAppControlReplyPtr& event);
virtual void OnRequestReceived(const EventApplicationFindAppControlPtr& event);
virtual void OnRequestReceived(const EventApplicationGetAppsContextPtr& event);
- virtual void OnRequestReceived(const EventApplicationGetAppContextPtr& event);
virtual void OnRequestReceived(const EventApplicationGetAppsInfoPtr& event);
- virtual void OnRequestReceived(const EventApplicationGetAppInfoPtr& event);
virtual void OnRequestReceived(const EventApplicationAddAppInfoEventListenerPtr& event);
virtual void OnRequestReceived(const EventApplicationRemoveAppInfoEventListenerPtr& event);
- virtual void OnRequestReceived(const EventApplicationGetAppCertsPtr& event);
- virtual void OnRequestReceived(const EventApplicationGetAppSharedURIPtr& event);
// inherited from IAppManagerAppListChangedCallbacks
virtual void onAppManagerEventInstalled(const char *appId);
EventApplicationAppInfoEventListenerEmitters m_installedApplicationsEmitters;
WatchIdMap m_watchIdMap;
- ApplicationPtr m_app;
};
class LaunchAppControlPendingEvent
using namespace WrtDeviceApis::Commons;
IApplicationManager::IApplicationManager() :
- EventRequestReceiver<EventApplicationGetCurrApp>(ThreadEnum::APPLICATION_THREAD),
EventRequestReceiver<EventApplicationLaunch>(ThreadEnum::APPLICATION_THREAD),
EventRequestReceiver<EventApplicationKill>(ThreadEnum::APPLICATION_THREAD),
EventRequestReceiver<EventApplicationLaunchAppControl>(ThreadEnum::APPLICATION_THREAD),
EventRequestReceiver<EventApplicationLaunchAppControlReply>(ThreadEnum::APPLICATION_THREAD),
EventRequestReceiver<EventApplicationFindAppControl>(ThreadEnum::APPLICATION_THREAD),
EventRequestReceiver<EventApplicationGetAppsContext>(ThreadEnum::APPLICATION_THREAD),
- EventRequestReceiver<EventApplicationGetAppContext>(ThreadEnum::APPLICATION_THREAD),
EventRequestReceiver<EventApplicationGetAppsInfo>(ThreadEnum::APPLICATION_THREAD),
- EventRequestReceiver<EventApplicationGetAppInfo>(ThreadEnum::APPLICATION_THREAD),
EventRequestReceiver<EventApplicationAddAppInfoEventListener>(ThreadEnum::APPLICATION_THREAD),
- EventRequestReceiver<EventApplicationRemoveAppInfoEventListener>(ThreadEnum::APPLICATION_THREAD),
- EventRequestReceiver<EventApplicationGetAppCerts>(ThreadEnum::APPLICATION_THREAD),
- EventRequestReceiver<EventApplicationGetAppSharedURI>(ThreadEnum::APPLICATION_THREAD)
+ EventRequestReceiver<EventApplicationRemoveAppInfoEventListener>(ThreadEnum::APPLICATION_THREAD)
{
}
#include <dpl/shared_ptr.h>
#include <Commons/ThreadPool.h>
-#include "EventApplicationGetCurrApp.h"
#include "EventApplicationLaunch.h"
#include "EventApplicationKill.h"
#include "EventApplicationLaunchAppControl.h"
#include "EventApplicationFindAppControl.h"
#include "EventApplicationGetAppsContext.h"
-#include "EventApplicationGetAppContext.h"
#include "EventApplicationGetAppsInfo.h"
-#include "EventApplicationGetAppInfo.h"
#include "EventApplicationAddAppInfoEventListener.h"
#include "EventApplicationRemoveAppInfoEventListener.h"
-#include "EventApplicationGetAppCerts.h"
-#include "EventApplicationGetAppSharedURI.h"
namespace DeviceAPI {
namespace Application {
class IApplicationManager :
- public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetCurrApp>,
public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationLaunch>,
public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationKill>,
public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationLaunchAppControl>,
public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationLaunchAppControlReply>,
public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationFindAppControl>,
public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetAppsContext>,
- public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetAppContext>,
public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetAppsInfo>,
- public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetAppInfo>,
public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationAddAppInfoEventListener>,
- public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationRemoveAppInfoEventListener>,
- public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetAppCerts>,
- public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationGetAppSharedURI>
+ public WrtDeviceApis::Commons::EventRequestReceiver<EventApplicationRemoveAppInfoEventListener>
{
public:
virtual ~IApplicationManager();
- virtual void getCurrentApplication(const EventApplicationGetCurrAppPtr& event) = 0;
virtual void launch(const EventApplicationLaunchPtr& event) = 0;
virtual void kill(const EventApplicationKillPtr& event) = 0;
virtual void launchAppControl(const EventApplicationLaunchAppControlPtr& event) = 0;
virtual void findAppControl(const EventApplicationFindAppControlPtr& event) = 0;
virtual void getAppsContext(const EventApplicationGetAppsContextPtr& event) = 0;
- virtual void getAppContext(const EventApplicationGetAppContextPtr& event) = 0;
virtual void getAppsInfo(const EventApplicationGetAppsInfoPtr& event) = 0;
- virtual void getAppInfo(const EventApplicationGetAppInfoPtr& event) = 0;
virtual void addAppInfoEventListener(const EventApplicationAddAppInfoEventListenerPtr& event) = 0;
virtual void removeAppInfoEventListener(const EventApplicationRemoveAppInfoEventListenerPtr& event) = 0;
- virtual void getAppCerts(const EventApplicationGetAppCertsPtr& event) = 0;
- virtual void getAppSharedURI(const EventApplicationGetAppSharedURIPtr& event) = 0;
protected:
IApplicationManager();
- virtual void OnRequestReceived(const EventApplicationGetCurrAppPtr& event) = 0;
virtual void OnRequestReceived(const EventApplicationLaunchPtr& event) = 0;
virtual void OnRequestReceived(const EventApplicationKillPtr& event) = 0;
virtual void OnRequestReceived(const EventApplicationLaunchAppControlPtr& event) = 0;
virtual void OnRequestReceived(const EventApplicationLaunchAppControlReplyPtr& event) = 0;
virtual void OnRequestReceived(const EventApplicationFindAppControlPtr& event) = 0;
virtual void OnRequestReceived(const EventApplicationGetAppsContextPtr& event) = 0;
- virtual void OnRequestReceived(const EventApplicationGetAppContextPtr& event) = 0;
virtual void OnRequestReceived(const EventApplicationGetAppsInfoPtr& event) = 0;
- virtual void OnRequestReceived(const EventApplicationGetAppInfoPtr& event) = 0;
virtual void OnRequestReceived(const EventApplicationAddAppInfoEventListenerPtr& event) = 0;
virtual void OnRequestReceived(const EventApplicationRemoveAppInfoEventListenerPtr& event) = 0;
- virtual void OnRequestReceived(const EventApplicationGetAppCertsPtr& event) = 0;
- virtual void OnRequestReceived(const EventApplicationGetAppSharedURIPtr& event) = 0;
};
typedef DPL::SharedPtr<IApplicationManager> IApplicationManagerPtr;
#include "ApplicationInformationEventPrivateData.h"
#include "JSApplicationEventCallbackManager.h"
#include "JSApplication.h"
+#include "ApplicationManager.h"
#include <TimeTracer.h>
#include <Export.h>
JSValueRef* exception)
{
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
- IApplicationManagerPtr appmgr;
- ApplicationController *controller;
try {
- controller = static_cast<ApplicationController*>(JSObjectGetPrivate(thisObject));
- if (!controller) {
- throw TypeMismatchException("No private object.");
- }
- appmgr = controller->getObject();
-
- EventApplicationGetCurrAppPtr event(new EventApplicationGetCurrApp());
- ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
-
- event->setForSynchronousCall();
- appmgr->getCurrentApplication(event);
-
- if (event->getExceptionCode() != WrtDeviceApis::Commons::ExceptionCodes::None) {
- throw UnknownException("Unknown exception occured");
- }
+ ApplicationPtr result = ApplicationManager::getCurrentApplication();
+ ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return JSApplication::makeObject(context, event->getApp());
+ return JSApplication::makeObject(context, result);
+
} catch (...) {
DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getCurrentApplication().");
return JSWebAPIErrorFactory::postException(context, exception, err);
}
-
JSValueRef JSApplicationManager::launch(JSContextRef context,
JSObjectRef object,
JSObjectRef thisObject,
{
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
TIME_TRACER_ITEM_BEGIN("launch(async)", 0);
-
+
+ TIME_TRACER_ITEM_BEGIN("launch(ACE)", 0);
AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_LAUNCH);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ TIME_TRACER_ITEM_END("launch(ACE)", 0);
try {
IApplicationManagerPtr appmgr;
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
TIME_TRACER_ITEM_BEGIN("kill(async)", 0);
+ TIME_TRACER_ITEM_BEGIN("kill(ACE)", 0);
AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_KILL);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ TIME_TRACER_ITEM_END("kill(ACE)", 0);
try {
IApplicationManagerPtr appmgr;
EventApplicationKillPtr event(new EventApplicationKill());
JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
-
ArgumentValidator validator(context, argumentCount, arguments);
// contextId
TIME_TRACER_ITEM_BEGIN("launchAppControl(async)", 0);
TIME_TRACER_ITEM_BEGIN("launchAppControlReply(async)", 0);
+ TIME_TRACER_ITEM_BEGIN("launchAppControl(ACE)", 0);
AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_LAUNCH_APP_CONTROL);
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ TIME_TRACER_ITEM_END("launchAppControl(ACE)", 0);
try {
IApplicationManagerPtr appmgr;
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
try {
- IApplicationManagerPtr appmgr;
- ApplicationController *controller;
-
- controller = static_cast<ApplicationController*>(JSObjectGetPrivate(thisObject));
- if (!controller) {
- throw TypeMismatchException("No private object.");
- }
- appmgr = controller->getObject();
-
- EventApplicationGetAppContextPtr event(new EventApplicationGetAppContext());
-
ArgumentValidator validator(context, argumentCount, arguments);
- // contextId
- std::string contextId = validator.toString(0, true, "");
- event->setAppContextId(contextId);
- event->setForSynchronousCall();
-
- appmgr->getAppContext(event);
-
- if (event->getExceptionCode() == ExceptionCodes::NotFoundException) {
- throw NotFoundException("Cannot found context with given context ID");
- } else if (event->getExceptionCode() != ExceptionCodes::None) {
- throw UnknownException("Unknown exception occured");
- }
+ ApplicationContextPtr result = ApplicationManager::getAppContext(validator.toString(0, true, ""));
+ ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
- ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return converter->toJSValueRefFromApplicationContext(event->getAppContext());
+ return converter->toJSValueRefFromApplicationContext(result);
+
} catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(context, exception, err);
- } catch (...) {
+ } catch (const WrtDeviceApis::Commons::NotFoundException& ex) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, ex.GetMessage());
+ } catch (...) {
DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppContext().");
return JSWebAPIErrorFactory::postException(context, exception, err);
}
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
try {
- IApplicationManagerPtr appmgr;
- ApplicationController *controller;
-
- controller = static_cast<ApplicationController*>(JSObjectGetPrivate(thisObject));
- if (!controller) {
- throw TypeMismatchException("No private object.");
- }
- appmgr = controller->getObject();
-
- EventApplicationGetAppInfoPtr event(new EventApplicationGetAppInfo());
-
- ArgumentValidator validator(context, argumentCount, arguments);
-
- // id
- std::string id = validator.toString(0, true, "");
- event->setAppId(id);
-
- event->setForSynchronousCall();
+ ArgumentValidator validator(context, argumentCount, arguments);
- appmgr->getAppInfo(event);
-
- if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
- throw NotFoundException("Given package not found.");
- } else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) {
- throw UnknownException("Unknown error occurred.");
- }
+ ApplicationInformationPtr result = ApplicationManager::getAppInfo(validator.toString(0, true, ""));
+ ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
- ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return converter->toJSValueRefFromApplicationInformation(event->getAppInfo());
-
+ return converter->toJSValueRefFromApplicationInformation(result);
+
} catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(context, exception, err);
- } catch (...) {
+ } catch (const WrtDeviceApis::Commons::NotFoundException& ex) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, ex.GetMessage());
+ } catch (...) {
DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppInfo().");
return JSWebAPIErrorFactory::postException(context, exception, err);
}
if (event->getExceptionCode() == ExceptionCodes::NotFoundException) {
throw NotFoundException("Watch id not found");
}
-else if (event->getExceptionCode() != ExceptionCodes::None) {
+ else if (event->getExceptionCode() != ExceptionCodes::None) {
throw UnknownException("UnknownException Occured");
}
{
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN("(getAppCerts)ACE", 0);
AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_GET_APP_CERTS);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ TIME_TRACER_ITEM_END("(getAppCerts)ACE", 0);
try {
- IApplicationManagerPtr appmgr;
- ApplicationController *controller;
-
- controller = static_cast<ApplicationController*>(JSObjectGetPrivate(thisObject));
- if (!controller) {
- throw TypeMismatchException("No private object.");
- }
- appmgr = controller->getObject();
-
- EventApplicationGetAppCertsPtr event(new EventApplicationGetAppCerts());
-
- ArgumentValidator validator(context, argumentCount, arguments);
-
- // id
- std::string id = validator.toString(0, true, "");
- event->setAppId(id);
-
- event->setForSynchronousCall();
+ ArgumentValidator validator(context, argumentCount, arguments);
- appmgr->getAppCerts(event);
+ ApplicationCertArrayPtr result = ApplicationManager::getAppCerts(validator.toString(0, true, ""));
+ ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
- if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
- throw NotFoundException("Given package not found.");
- } else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) {
- throw UnknownException("Unknown error occurred.");
- }
-
- ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return converter->toJSValueRefFromeApplicationCerts(event->getAppCerts());
-
+ return converter->toJSValueRefFromeApplicationCerts(result);
+
} catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(context, exception, err);
- } catch (...) {
+ } catch (const WrtDeviceApis::Commons::NotFoundException& ex) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, ex.GetMessage());
+ } catch (...) {
DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppCerts().");
return JSWebAPIErrorFactory::postException(context, exception, err);
}
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
try {
- IApplicationManagerPtr appmgr;
- ApplicationController *controller;
-
- controller = static_cast<ApplicationController*>(JSObjectGetPrivate(thisObject));
- if (!controller) {
- throw TypeMismatchException("No private object.");
- }
- appmgr = controller->getObject();
-
- EventApplicationGetAppSharedURIPtr event(new EventApplicationGetAppSharedURI());
-
- ArgumentValidator validator(context, argumentCount, arguments);
-
- // id
- std::string id = validator.toString(0, true, "");
- event->setAppId(id);
-
- event->setForSynchronousCall();
+ ArgumentValidator validator(context, argumentCount, arguments);
- appmgr->getAppSharedURI(event);
-
- if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
- throw NotFoundException("Given package not found.");
- } else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) {
- throw UnknownException("Unknown error occurred.");
- }
+ std::string result = ApplicationManager::getAppSharedURI(validator.toString(0, true, ""));
+ ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
- ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return converter->toJSValueRef(event->getSharedURI());
+ return converter->toJSValueRef(result);
} catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(context, exception, err);
- } catch (...) {
+ } catch (const WrtDeviceApis::Commons::NotFoundException& ex) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, ex.GetMessage());
+ } catch (...) {
DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppSharedURI().");
return JSWebAPIErrorFactory::postException(context, exception, err);
}
#include "ApplicationUtil.h"
#include "JSRequestedApplicationControl.h"
#include <Export.h>
+
+#include <TimeTracer.h>
+
#include <Logger.h>
using namespace WrtDeviceApis::Commons;
const JSValueRef arguments[],
JSValueRef* exception)
{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
JSRequestedApplicationControlPriv *priv = static_cast<JSRequestedApplicationControlPriv*>(JSObjectGetPrivate(thisObject));
Try {
resultArray = converter->toApplicationControlDataArray(arguments[0]);
}
providerMgr->replyResult(resultArray);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 0);
} Catch (ConversionException) {
LoggerE("Exception: "<<_rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception,JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
const JSValueRef arguments[],
JSValueRef* exception)
{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
JSRequestedApplicationControlPriv *priv = static_cast<JSRequestedApplicationControlPriv*>(JSObjectGetPrivate(thisObject));
Try {
RequestedApplicationControlPtr providerMgr = priv->getObject();
providerMgr->replyFailure();
+ TIME_TRACER_ITEM_END(__FUNCTION__, 0);
} Catch (NotFoundException) {
LoggerE("Exception: "<<_rethrown_exception.GetMessage());
return JSWebAPIErrorFactory::postException(context, exception,JSWebAPIErrorFactory::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
#include <app_service.h>
#include <app_manager.h>
#include "RequestedApplicationControl.h"
+
+#include <TimeTracer.h>
+
#include <Logger.h>
namespace DeviceAPI {
ThrowMsg(NotFoundException, "Cannot find caller");
} else {
bool running = false;
+ TIME_TRACER_ITEM_BEGIN("(replyResult)app_manager_is_running", 0);
int ret = app_manager_is_running(m_callerAppId.c_str(), &running);
+ TIME_TRACER_ITEM_END("(replyResult)app_manager_is_running", 0);
if ((ret != APP_MANAGER_ERROR_NONE) || !running) {
LoggerE("caller is not running");
ThrowMsg(NotFoundException, "Cannot find caller");
}
}
+ TIME_TRACER_ITEM_BEGIN("(replyResult)service_reply_to_launch_request", 0);
if (service_reply_to_launch_request(reply, m_appControl->getService_h(), SERVICE_RESULT_SUCCEEDED) != SERVICE_ERROR_NONE) {
ThrowMsg(NotFoundException, "Cannot find caller");
}
+ TIME_TRACER_ITEM_END("(replyResult)service_reply_to_launch_request", 0);
service_destroy(reply);
}
ThrowMsg(NotFoundException, "Cannot find caller");
} else {
bool running = false;
+ TIME_TRACER_ITEM_BEGIN("(replyFailure)app_manager_is_running", 0);
int ret = app_manager_is_running(m_callerAppId.c_str(), &running);
+ TIME_TRACER_ITEM_END("(replyFailure)app_manager_is_running", 0);
if ((ret != APP_MANAGER_ERROR_NONE) || !running) {
LoggerE("caller is not running");
ThrowMsg(NotFoundException, "Cannot find caller");
}
}
+ TIME_TRACER_ITEM_BEGIN("(replyFailure)service_reply_to_launch_request", 0);
if (service_reply_to_launch_request(reply, m_appControl->getService_h(), SERVICE_RESULT_FAILED) != SERVICE_ERROR_NONE) {
ThrowMsg(NotFoundException, "Cannot find caller");
}
+ TIME_TRACER_ITEM_END("(replyFailure)service_reply_to_launch_request", 0);
service_destroy(reply);
}
Calendar();
virtual ~Calendar();
+ virtual void addEvent(IEventAddEventPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void updateEvent(IEventUpdateEventPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void deleteEvent(IEventDeleteEventPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void createEventFromString(IEventCreateEventFromStringPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void exportEventToString(IEventExportEventToStringPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void watchChanges(IEventWatchChangesPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void clearWatch(IEventClearWatchPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void get(IEventGetPtr &event) {
+ OnRequestReceived(event);
+ }
+
protected:
virtual void OnRequestReceived(const IEventAddEventPtr &event);
virtual void OnRequestReceived(const IEventAddEventsPtr &events);
CalendarManager();
virtual ~CalendarManager();
+ virtual void getDefaultCalendar(const IEventGetDefaultCalendarPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void getUnifiedCalendar(const IEventGetUnifiedCalendarPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void getCalendar(const IEventGetCalendarPtr &event) {
+ OnRequestReceived(event);
+ }
+
protected:
virtual void OnRequestReceived(const IEventGetCalendarsPtr &event);
virtual void OnRequestReceived(const IEventGetDefaultCalendarPtr &event);
namespace Calendar {
ICalendar::ICalendar() :
- WrtDeviceApis::Commons::EventRequestReceiver<IEventAddEvent>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver<IEventAddEvents>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteEvent>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteEvents>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateEvent>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateEvents>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver<IEventFindEvents>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver<IEventCreateEventFromString>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver<IEventExportEventToString>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver<IEventWatchChanges>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver<IEventClearWatch>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver<IEventExpandEventRecurrence>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver<IEventGet>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventAddEvent>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventAddEvents>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteEvent>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteEvents>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateEvent>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateEvents>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventFindEvents>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventCreateEventFromString>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventExportEventToString>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventWatchChanges>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventClearWatch>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventExpandEventRecurrence>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver<IEventGet>(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
m_id(UNDEFINED_ID),
m_accountId(UNDEFINED_CALENDAR_ID),
m_name(""),
namespace Calendar {
ICalendarManager::ICalendarManager() :
- WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendars >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver< IEventGetDefaultCalendar >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver< IEventGetUnifiedCalendar >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendar >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD)
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendars >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventGetDefaultCalendar >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventGetUnifiedCalendar >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendar >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD)
{
}
LoggerD("data null, can not send result to JS Layer");
return;
}
+
+ pendingEvent = (EventGetValuePendingEvent *)data;
if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC())
{
LoggerD("private object is garbage collected");
+ delete pendingEvent;
return;
}
- pendingEvent = (EventGetValuePendingEvent *)data;
consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
event = pendingEvent->getEvent();
return;
}
+ pendingEvent = (EventAddValuePendingEvent *)data;
+
if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC())
{
LoggerD("private object is garbage collected");
+ delete pendingEvent;
return;
}
-
-
- pendingEvent = (EventAddValuePendingEvent *)data;
+
consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
event = pendingEvent->getEvent();
return;
}
-
+ pendingEvent = (EventRemoveValuePendingEvent *)data;
+
if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC())
{
LoggerD("private object is garbage collected");
+ delete pendingEvent;
return;
}
-
- pendingEvent = (EventRemoveValuePendingEvent *)data;
+
consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
event = pendingEvent->getEvent();
return;
}
+ pendingEvent = (EventUpdateValuePendingEvent *)data;
+
if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC())
{
LoggerD("private object is garbage collected");
+ delete pendingEvent;
return;
}
-
- pendingEvent = (EventUpdateValuePendingEvent *)data;
+
consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
event = pendingEvent->getEvent();
return;
}
+ pendingEvent = (EventSelectPendingEvent *)data;
+
if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
{
LoggerD("private object is garbage collected");
+ delete pendingEvent;
return;
}
-
- pendingEvent = (EventSelectPendingEvent *)data;
+
consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
event = pendingEvent->getEvent();
return;
}
+ pendingEvent = (EventInsertPendingEvent *)data;
+
if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
{
LoggerD("private object is garbage collected");
+ delete pendingEvent;
return;
}
-
-
- pendingEvent = (EventInsertPendingEvent *)data;
+
consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
event = pendingEvent->getEvent();
return;
}
- if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
- {
- LoggerD("private object is garbage collected");
- return;
- }
-
EventDeletePendingEvent* pendingEvent = NULL;
SQLDataControlConsumer *consumer = NULL;
EventDeletePtr event;
}
pendingEvent = (EventDeletePendingEvent *)data;
+
+ if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
+ {
+ LoggerD("private object is garbage collected");
+ delete pendingEvent;
+ return;
+ }
+
consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
event = pendingEvent->getEvent();
return;
}
+
+ pendingEvent = (EventUpdatePendingEvent *)data;
+
if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
{
LoggerD("private object is garbage collected");
+ delete pendingEvent;
return;
}
-
-
- pendingEvent = (EventUpdatePendingEvent *)data;
consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
event = pendingEvent->getEvent();
}
}
}
-
+ msg_release_struct(&mms_struct);
}
{
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN("install(ACE)", 0);
AceSecurityStatus status = PACKAGE_CHECK_ACCESS(PACKAGE_FUNCTION_API_INSTALL);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ TIME_TRACER_ITEM_END("install(ACE)", 0);
try {
ArgumentValidator validator(context, argumentCount, arguments);
{
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN("uninstall(ACE)", 0);
AceSecurityStatus status = PACKAGE_CHECK_ACCESS(PACKAGE_FUNCTION_API_INSTALL);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ TIME_TRACER_ITEM_END("uninstall(ACE)", 0);
try {
ArgumentValidator validator(context, argumentCount, arguments);
{
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN("getPackagesInfo(ACE)", 0);
AceSecurityStatus status = PACKAGE_CHECK_ACCESS(PACKAGE_FUNCTION_API_GET_PACKAGES_INFO);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ TIME_TRACER_ITEM_END("getPackagesInfo(ACE)", 0);
try {
ArgumentValidator validator(context, argumentCount, arguments);
{
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN("(getPackageInfo) ACE", 0);
AceSecurityStatus status = PACKAGE_CHECK_ACCESS(PACKAGE_FUNCTION_API_GET_PACKAGE_INFO);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ TIME_TRACER_ITEM_END("(getPackageInfo) ACE", 0);
try {
ArgumentValidator validator(context, argumentCount, arguments);
{
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN("(setPackageInfoEventListener) ACE", 0);
AceSecurityStatus status = PACKAGE_CHECK_ACCESS(PACKAGE_FUNCTION_API_SET_PACKAGE_INFO_EVENT_LISTENER);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ TIME_TRACER_ITEM_END("(setPackageInfoEventListener) ACE", 0);
try {
ArgumentValidator validator(context, argumentCount, arguments);
{
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN("(unsetPackageInfoEventListener) ACE", 0);
AceSecurityStatus status = PACKAGE_CHECK_ACCESS(PACKAGE_FUNCTION_API_UNSET_PACKAGE_INFO_EVENT_LISTENER);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ TIME_TRACER_ITEM_END("(unsetPackageInfoEventListener) ACE", 0);
try {
PackageManager::getInstance()->unsetPackageInfoEventListener();
#include "PackageManager.h"
#include "PackageInformation.h"
#include "JSPackageInformation.h"
+
+#include <TimeTracer.h>
+
#include <Logger.h>
using namespace WrtDeviceApis::Commons;
if (pkgId.empty() || !pkgId.compare("null")) {
char *pkg_id = NULL;
+ TIME_TRACER_ITEM_BEGIN("(getPackageInfo) get_current_pkg_id", 0);
int ret = get_current_pkg_id(&pkg_id);
+ TIME_TRACER_ITEM_END("(getPackageInfo) get_current_pkg_id", 0);
if((ret != APP_MANAGER_ERROR_NONE) || (pkg_id == NULL)) {
LoggerE("Can not get app id from current pid");
throw NotFoundException("Can't find given package");
}
pkgmgrinfo_pkginfo_h handle;
+ TIME_TRACER_ITEM_BEGIN("(getPackageInfo) pkgmgrinfo_pkginfo_get_pkginfo", 0);
int ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgId.c_str(), &handle);
+ TIME_TRACER_ITEM_END("(getPackageInfo) pkgmgrinfo_pkginfo_get_pkginfo", 0);
if (ret != PMINFO_R_OK) {
throw NotFoundException("Can't find given package");
}
+ TIME_TRACER_ITEM_BEGIN("(getPackageInfo) create_pkg_info", 0);
PackageInformation* pkgInfo = create_pkg_info(handle);
+ TIME_TRACER_ITEM_END("(getPackageInfo) create_pkg_info", 0);
pkgmgrinfo_appinfo_destroy_appinfo(handle);
if (pkgInfo == NULL) {
void PackageManager::setPackageInfoEventListener(PackageInfoEventCallback * eventCB)
{
if (m_manager_handle == NULL) {
+ TIME_TRACER_ITEM_BEGIN("(setPackageInfoEventListener) pkgmgr_client_new", 0);
m_manager_handle = pkgmgr_client_new(PC_LISTENING);
+ TIME_TRACER_ITEM_END("(setPackageInfoEventListener) pkgmgr_client_new", 0);
if (m_manager_handle == NULL) {
throw UnknownException("Fail to create package manager handle");
}
eventCB->setEventHandler(&m_manager_handle);
+ TIME_TRACER_ITEM_BEGIN("(setPackageInfoEventListener) pkgmgr_client_listen_status", 0);
pkgmgr_client_listen_status(m_manager_handle, app_list_changed_cb_broker, eventCB);
+ TIME_TRACER_ITEM_END("(setPackageInfoEventListener) pkgmgr_client_listen_status", 0);
}
void PackageManager::unsetPackageInfoEventListener()
return;
}
+ TIME_TRACER_ITEM_BEGIN("(unsetPackageInfoEventListener) pkgmgr_client_free", 0);
pkgmgr_client_free(m_manager_handle);
+ TIME_TRACER_ITEM_END("(unsetPackageInfoEventListener) pkgmgr_client_free", 0);
m_manager_handle = NULL;
}