Name: wrt-plugins-tizen
Summary: JavaScript plugins for WebRuntime
-Version: 0.4.35
+Version: 0.4.36
Release: 0
Group: Development/Libraries
License: Apache License, Version 2.0
m_manager_handle = NULL;
}
-// @20130125-wscho: current pkgmanager has a problem while db operation.
-// So, below function is temporal function. all attribute should be filled to appInfoObject
-// when that is created.
-// See ApplicationManager.cpp
bool AppManagerWrapper::initializeAppInfo(ApplicationInformationPtr &appInfo)
{
- std::string appId = appInfo->getAppId();
+ LoggerD("Enter");
+
char* packageId = NULL;
int ret = 0;
- ret = package_manager_get_package_id_by_app_id(appId.c_str(), &packageId);
- if (ret != PACKAGE_MANAGER_ERROR_NONE)
- {
+ ret = package_manager_get_package_id_by_app_id(appInfo->getAppId().c_str(), &packageId);
+ if ((ret != PACKAGE_MANAGER_ERROR_NONE) || (packageId == NULL)) {
LoggerE("Fail to get package id");
- }
-
-// Below code is already run on ApplicationManager.cpp
-#if 0
- char* name = NULL;
- char* iconPath = NULL;
- bool noDisplay = false;
- pkgmgrinfo_appinfo_h appinfo_h;
-
- ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &appinfo_h);
- if (ret != PMINFO_R_OK) {
- LoggerE("Fail to get appinfo");
- }
-
- ret = pkgmgrinfo_appinfo_get_label(appinfo_h, &name);
- if (ret != PMINFO_R_OK) {
- LoggerE("Fail to get name");
- }
- appInfo->setName(name);
-
- ret = pkgmgrinfo_appinfo_get_icon(appinfo_h, &iconPath);
- if (ret != PMINFO_R_OK) {
- LoggerE("Fail to get icon");
- }
- appInfo->setIconPath(iconPath);
-
- ret = pkgmgrinfo_appinfo_is_nodisplay(appinfo_h, &noDisplay);
- if (ret != PMINFO_R_OK) {
- LoggerE("Fail to get nodisplay");
- }
- appInfo->setShow(!noDisplay);
-
- ret = pkgmgrinfo_appinfo_foreach_category(appinfo_h, category_cb, (void*)appInfo.Get());
- if (ret < 0)
- {
- LoggerE("Fail to get categories");
- }
-
- ret = pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
- if (ret < 0)
- {
- LoggerE("Fail to destroy ");
- }
-#endif
-
- char *version = NULL;
- int total_size = 0;
- int installed_time = 0;
- pkgmgrinfo_pkginfo_h pkginfo_h;
-
- ret = pkgmgrinfo_pkginfo_get_pkginfo(packageId, &pkginfo_h);
- if (ret != PMINFO_R_OK) {
- LoggerE("Fail to get package info");
- }
-
- ret = pkgmgrinfo_pkginfo_get_version(pkginfo_h, &version);
- if (ret != PMINFO_R_OK) {
- LoggerE("Fail to get version");
- }
- appInfo->setVersion(version);
+ } else {
+ // get installed size from package server (to solve smack issue)
+ pkgmgr_client *pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ LoggerE("Fail to create pkgmgr client");
+ } else {
+ ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE, pc, NULL, packageId, NULL, NULL, NULL);
+ if (ret < 0) {
+ LoggerE("Fail to get installed size");
+ } else {
+ appInfo->setInstallSize(ret);
+ }
- ret = pkgmgrinfo_pkginfo_get_total_size(pkginfo_h, &total_size);
- if (ret == PMINFO_R_OK) {
- LoggerE("Fail to get installed size");
- appInfo->setInstallSize(total_size);
- }
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
- ret = pkgmgrinfo_pkginfo_get_installed_time(pkginfo_h, &installed_time);
- if (ret == PMINFO_R_OK) {
- LoggerE("Fail to get installed date");
- appInfo->setInstallDate(installed_time);
+ if (packageId) {
+ free(packageId);
+ }
}
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo_h);
-
+ // if error occured, retry? or not?
appInfo->setInitialize();
+
return true;
}
#include "JSApplicationEventCallbackManager.h"
#include "ApplicationAsyncCallbackManager.h"
#include "ApplicationInformationEventPrivateData.h"
+
+// to unset event callback for kill() API
+#include <app_manager.h>
+
#include <Logger.h>
namespace DeviceAPI {
void ApplicationAsyncAnswerHandler::kill(const EventApplicationKillPtr &event)
{
+ // unset event callback to avoid additional event comes
+ app_manager_unset_app_context_event_cb();
+
JSCallbackManagerPtr callbackManager =
DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
if (!callbackManager) {
return true;
}
-#if 0
- // @20130125-wscho: current pkgmanager has a problem while db operation.
- // So, if enable below code, foreach callback of "pkgmgrinfo_appinfo_get_installed_list"
- // is not running.
- // So, temporally, we get version, total size, installed time on first access for that attribute.
- // See JSApplicationInformation.cpp
- static void set_additional_app_info(ApplicationInformationPtr &appInfo, const char* packageId)
- {
- int ret = 0;
- char *version = NULL;
- int total_size = 0;
- int installed_time = 0;
- pkgmgrinfo_pkginfo_h pkginfo_h;
-
- ret = pkgmgrinfo_pkginfo_get_pkginfo(packageId, &pkginfo_h);
- if (ret != PMINFO_R_OK) {
- LoggerD("Fail to get package info. skip getting info");
- return;
- }
-
- ret = pkgmgrinfo_pkginfo_get_version(pkginfo_h, &version);
- if ((ret != PMINFO_R_OK) || (version == NULL)) {
- LoggerD("Fail to get version");
- } else {
- appInfo->setVersion(version);
- }
-
- ret = pkgmgrinfo_pkginfo_get_total_size(pkginfo_h, &total_size);
- if (ret != PMINFO_R_OK) {
- LoggerD("Fail to get total size");
- } else {
- appInfo->setInstallSize(total_size);
- }
-
- ret = pkgmgrinfo_pkginfo_get_installed_time(pkginfo_h, &installed_time);
- if (ret != PMINFO_R_OK) {
- LoggerD("Fail to get installed time");
- } else {
- appInfo->setInstallDate(installed_time);
- }
-
- ret = pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo_h);
- if (ret != PMINFO_R_OK) {
- LoggerD("Fail to get destroy pkginfo");
- }
- }
-#endif
-
static ApplicationInformationPtr create_app_info(pkgmgrinfo_appinfo_h handle)
{
char* appId = NULL;
appInfo->setPackageId(pkgId);
}
+ char *version = NULL;
+ int installed_time = 0;
+ pkgmgrinfo_pkginfo_h pkginfo_h;
-// @20130125-wscho: current pkgmanager has a problem while db operation.
-// So, if enable below code, foreach callback of "pkgmgrinfo_appinfo_get_installed_list"
-// is not running.
-// So, temporally, we get version, total size, installed time on first access for that attribute.
-// See JSApplicationInformation.cpp
-#if 0
- ret = pkgmgrinfo_appinfo_get_pkgname(handle, &packageId);
- if (ret != PMINFO_R_OK)
- {
- LoggerD("Fail to get package id");
- return appInfo;
- }
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgId, &pkginfo_h);
+ if (ret != PMINFO_R_OK) {
+ LoggerE("Fail to get package info");
+ } else {
+ ret = pkgmgrinfo_pkginfo_get_version(pkginfo_h, &version);
+ if (ret != PMINFO_R_OK) {
+ LoggerE("Fail to get version");
+ } else {
+ appInfo->setVersion(version);
+ }
- set_additional_app_info(appInfo, packageId);
-#endif
+ ret = pkgmgrinfo_pkginfo_get_installed_time(pkginfo_h, &installed_time);
+ if (ret != PMINFO_R_OK) {
+ LoggerE("Fail to get installed date");
+ } else {
+ appInfo->setInstallDate(installed_time);
+ }
+ pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo_h);
+ }
+
+ // remark : attribute "total size" is set at first attribute access time for performance.
return appInfo;
-
}
}
gLaunchAppControlPendingEventMap.eraseKey(this);
+
+ // unset context event callback which is registered by kill().
+ app_manager_unset_app_context_event_cb();
}
void ApplicationManager::launch(const EventApplicationLaunchPtr& event)
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)
+ if ((result != PACKAGE_MANAGER_ERROR_NONE) && (result != PACKAGE_MANAGER_ERROR_IO_ERROR))
{
ThrowMsg(UnknownException, "Can not get package cert info");
}
return converter.toJSValueRef(privateData->getCategories());
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_PACKAGE_ID)) {
return converter.toJSValueRef(privateData->getPackageId());
+ } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_VERSION)) {
+ return converter.toJSValueRef(privateData->getVersion());
+ } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_INSTALL_DATE)) {
+ return converter.toJSValueRef(privateData->getInstallDate());
} else {
-// below code is temporal. if package manager issue is solved, rollback this code.
-#if 1 // below code is used to fill attribute lazy
if (!privateData->isInitialized()) {
AppManagerWrapperSingleton::Instance().initializeAppInfo(privateData);
}
-#endif
- if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_VERSION)) {
- return converter.toJSValueRef(privateData->getVersion());
- } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_INSTALL_DATE)) {
- return converter.toJSValueRef(privateData->getInstallDate());
- } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_INSTALL_SIZE)) {
+
+ if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_INFORMATION_INSTALL_SIZE)) {
return converter.toJSValueRefLong(privateData->getInstallSize());
}
}
result->setEndDate((long long int) (timeUtilConverter.getTimeInMilliseconds(untilDateData)/1000));
result->setTimeZone(timeUtilConverter.getPropertiesInTZDate(untilDateData).timezone);
} else {
- result->setEndDate(0);
+ result->setEndDate(UNDEFINED_TIME);
}
}
if (!JSValueIsUndefined(m_context, occurrenceCountData)) {
}
if (!JSValueIsUndefined(m_context, durationData) && !JSValueIsNull(m_context, durationData)) {
- long long length = timeUtilConverter.getDurationLength(durationData);
- int unit = timeUtilConverter.getDurationUnit(durationData);
+ DurationPropertiesPtr duration = timeUtilConverter.getDuration(durationData);
+ long long length = duration->length;
+ int unit = duration->unit;
LoggerD("duration length: "<<length<<", unit "<<unit);
- if( MSECS_UNIT==unit ) {
- result->setEndTime(result->getStartTime() + length/1000);
- } else if( SECONDS_UNIT==unit ) {
- result->setEndTime(result->getStartTime() + length);
- } else if ( MINUTES_UNIT==unit ) {
- result->setEndTime(result->getStartTime() + length*60);
- } else if ( HOURS_UNIT==unit ) {
- result->setEndTime(result->getStartTime() + length*60*60);
- } else if ( DAYS_UNIT==unit ) {
- result->setEndTime(result->getStartTime() + length*24*60*60);
- } else {
- ThrowMsg(ConversionException, "Wrong duration unit.");
- }
- result->getDuration()->length = length;
- result->getDuration()->unit = unit;
+ result->setDuration(duration);
}
if (!JSValueIsUndefined(m_context, locationData)) {
result->setLocation(toString(locationData));
// limitations under the License.
//
+
#include <sstream>
#include <algorithm>
#include <time.h>
#include "Calendar.h"
#include "CalendarUtility.h"
#include <Logger.h>
+#include <DurationProperties.h>
using namespace WrtDeviceApis::Commons;
int ret;
long long int time = m_abstractEvent->getEndTime();
if (time == UNDEFINED_TIME) {
- time = m_abstractEvent->getStartTime();
+ if(0<m_abstractEvent->getDuration()->length) {
+ long long length = m_abstractEvent->getDuration()->length;
+ int unit = m_abstractEvent->getDuration()->unit;
+
+ if( DeviceAPI::Time::SECONDS_UNIT==unit ) {
+ time = m_abstractEvent->getStartTime() + length;
+ } else if ( DeviceAPI::Time::MINUTES_UNIT==unit ) {
+ time = m_abstractEvent->getStartTime() + length*60;
+ } else if ( DeviceAPI::Time::HOURS_UNIT==unit ) {
+ time = m_abstractEvent->getStartTime() + length*60*60;
+ } else if ( DeviceAPI::Time::DAYS_UNIT==unit ) {
+ time = m_abstractEvent->getStartTime() + length*24*60*60;
+ } else if ( DeviceAPI::Time::MSECS_UNIT==unit ) {
+ time = m_abstractEvent->getStartTime() + length/1000;
+ } else {
+ LoggerD("Wrong duration unit: "<<unit);
+ }
+ LoggerD("Set the end time from the duration: "<<time);
+ } else {
+ time = m_abstractEvent->getStartTime();
+ LoggerD("Set the end time from the start time: "<<time);
+ }
}
calendar_time_s cal;
#include <JSWebAPIErrorFactory.h>
#include <SecurityExceptions.h>
#include <TimeUtilConverter.h>
+#include <JSTimeDuration.h>
#include <JSTZDate.h>
#include <JSSimpleCoordinates.h>
#include "EventAlarm.h"
Try
{
CalendarEventPtr item = getPrivateObject(object);
- TimeUtilConverter converter(context);
- DurationProperties duration;
if(UNDEFINED_TIME!=item->getDuration()->length) {
- duration.length = item->getDuration()->length;
- duration.unit = item->getDuration()->unit;
- LoggerD("Duration length: "<<duration.length<<", unit: "<<duration.unit);
- return converter.makeDurationObject( duration );
+ LoggerD("Duration length: "<<item->getDuration()->length<<", unit: "<<item->getDuration()->unit);
+ return JSTimeDuration::createJSObject(context, item->getDuration());
}
// Alternatively generate the duration object using start/end time.
long long length = item->getEndTime() - item->getStartTime(); // in seconds only
LoggerD("item->getStartTime():"<< item->getStartTime() << ", length:" << length);
- duration.length = length;
- duration.unit = SECONDS_UNIT;
- return converter.makeDurationObject( duration );
+ DurationPropertiesPtr durationPtr(new DurationProperties());
+ durationPtr->length = length;
+ durationPtr->unit = SECONDS_UNIT;
+ item->setDuration(durationPtr);
+
+ return JSTimeDuration::createJSObject(context, durationPtr);
}
Catch(Exception)
{
Try
{
CalendarEventPtr event = getPrivateObject(object);
- TimeUtilConverter converter(context);
- long long length = converter.getDurationLength(value);
- int unit = converter.getDurationUnit(value);
+ TimeUtilConverter timeUtilConverter(context);
+
+ DurationPropertiesPtr duration = timeUtilConverter.getDuration(value);
+ long long length = duration->length;
+ int unit = duration->unit;
if (length < 0) {
DeviceAPI::Common::JSWebAPIErrorFactory::postException(context, exception, DeviceAPI::Common::JSWebAPIErrorFactory::INVALID_VALUES_ERROR);
return false;
}
- if( SECONDS_UNIT==unit ) {
- event->setEndTime(event->getStartTime() + length);
- } else if ( MINUTES_UNIT==unit ) {
- event->setEndTime(event->getStartTime() + length*60);
- } else if ( HOURS_UNIT==unit ) {
- event->setEndTime(event->getStartTime() + length*60*60);
- } else if ( DAYS_UNIT==unit ) {
- event->setEndTime(event->getStartTime() + length*24*60*60);
- } else if ( MSECS_UNIT==unit ) {
- event->setEndTime(event->getStartTime() + length/1000);
- } else {
- DeviceAPI::Common::JSWebAPIErrorFactory::postException(context, exception, DeviceAPI::Common::JSWebAPIErrorFactory::INVALID_VALUES_ERROR);
- return false;
- }
- event->getDuration()->length = length;
- event->getDuration()->unit = unit;
+ LoggerD("length: "<<length<< ", unit:" <<unit);
+ event->setDuration(duration);
return true;
}
//
#include "ResponseDispatcher.h"
-#include <dpl/assert.h>
#include <Commons/Exception.h>
#include <Commons/IEvent.h>
#include <CommonsJavaScript/JSUtils.h>
#include <map>
#include <utility>
-#include <dpl/assert.h>
#include <Commons/FunctionDefinition.h>
#include <Commons/FunctionDeclaration.h>
#include <Commons/Exception.h>
void ContactsSvcChangeListenerManager::personsDbChangedCallback(const char* view_uri, char* changes, void* user_data)
{
- LoggerD("entered");
+ LoggerD("entered : " << changes);
+
+ if(changes == NULL)
+ {
+ LoggerW("changes is NULL");
+ return;
+ }else{
+ if(strlen(changes) == 0){
+ LoggerW("changes is empty");
+ return;
+ }
+ }
if(user_data == NULL)
{
int tmpUpdatedType = 0;
int tmpUpdatedContactId = 0;
- char* ptr;
- char* sub_ptr;
-
- ptr = strtok(changes, ",");
+ char* sub_ptr = NULL;
- sub_ptr = strtok(ptr, ":");
- tmpUpdatedType = atoi((const char*)sub_ptr);
- sub_ptr = strtok(NULL, ptr);
- tmpUpdatedContactId = atoi((const char*)sub_ptr);
- idList.insert(pair<int, int>(tmpUpdatedType, tmpUpdatedContactId));
+ char* tmp = g_strdup(changes);
+ LoggerD("tmp : " << tmp);
- while(ptr = strtok(NULL, changes))
+ sub_ptr = strtok(tmp, " ,:");
+ while(sub_ptr != NULL)
{
- sub_ptr = strtok(ptr, ":");
- tmpUpdatedType = atoi((const char*)sub_ptr);
- sub_ptr = strtok(NULL, ptr);
- tmpUpdatedContactId = atoi((const char*)sub_ptr);
- idList.insert(pair<int, int>(tmpUpdatedType, tmpUpdatedContactId));
+ if(validate("^[0-9]+$", sub_ptr, VALIDATE_MATCH_CASELESS))
+ {
+ tmpUpdatedType = atoi((const char*)sub_ptr);
+ sub_ptr = strtok(NULL, " ,:");
+ if(validate("^[0-9]+$", sub_ptr, VALIDATE_MATCH_CASELESS))
+ {
+ tmpUpdatedContactId = atoi((const char*)sub_ptr);
+ idList.insert(pair<int, int>(tmpUpdatedType, tmpUpdatedContactId));
+ }
+ }
+ sub_ptr = strtok(NULL, " ,:");
}
+ g_free(tmp);
PersonsChangeListenerSet::iterator callbacksIter = m_personsChangeListenerSet.begin();
for(; callbacksIter != m_personsChangeListenerSet.end(); callbacksIter++)
public:
DataControlAsyncCallbackManager()
{
- m_sqlDataControlGC = false;
- m_mappedDataControlGC = false;
}
virtual ~DataControlAsyncCallbackManager()
cleanupSQLUserData();
}
- bool isSQLDataControlGC() { return m_sqlDataControlGC;}
- bool isMappedDataControlGC() { return m_mappedDataControlGC;}
- void setSQLDataControlGC(bool gc) { m_sqlDataControlGC = gc;}
- void setMappedDataControlGC(bool gc) { m_mappedDataControlGC = gc;}
+ bool isSQLDataControlGC(void* address)
+ {
+ LoggerD(address);
+
+ if (m_sqlDataControlGCMap.find(address) == m_sqlDataControlGCMap.end())
+ {
+ return true;
+ }
+
+ return m_sqlDataControlGCMap[address];
+ }
+ bool isMappedDataControlGC(void* address)
+ {
+ LoggerD(address);
+
+ if (m_mappedDataControlGCMap.find(address) == m_sqlDataControlGCMap.end())
+ {
+ return true;
+ }
+
+ return m_mappedDataControlGCMap[address];
+ }
+ void setSQLDataControlGC(void* address, bool gc)
+ {
+ LoggerD(address);
+
+ DPL::Mutex::ScopedLock lock(&m_mutex);
+ if (gc && m_sqlDataControlGCMap.find(address) != m_sqlDataControlGCMap.end())
+ {
+ m_mappedDataControlGCMap.erase(address);
+ }
+ m_sqlDataControlGCMap[address] = gc;
+ }
+
+ void setMappedDataControlGC(void* address, bool gc)
+ {
+ LoggerD(address);
+
+ DPL::Mutex::ScopedLock lock(&m_mutex);
+ if (gc && m_mappedDataControlGCMap.find(address) != m_mappedDataControlGCMap.end())
+ {
+ m_mappedDataControlGCMap.erase(address);
+ }
+ m_mappedDataControlGCMap[address] = gc;
+ }
+
bool checkReqIdUnique(std::string key)
{
if (m_callbackSQLUserDataMap.find(key) == m_callbackSQLUserDataMap.end())
}
}
DPL::Mutex m_mutex;
- bool m_sqlDataControlGC;
- bool m_mappedDataControlGC;
+ std::map<void*, bool> m_sqlDataControlGCMap;
+ std::map<void*, bool> m_mappedDataControlGCMap;
std::map<std::string, void*> m_callbackSQLUserDataMap;
};
}
pendingEvent = (EventGetValuePendingEvent *)data;
-
- if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC())
+ consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
+
+ if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC((void*)consumer))
{
LoggerD("private object is garbage collected");
delete pendingEvent;
return;
}
-
- consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
+
event = pendingEvent->getEvent();
if (b == NULL)
}
pendingEvent = (EventAddValuePendingEvent *)data;
+ consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
- if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC())
+ if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC((void*)consumer))
{
LoggerD("private object is garbage collected");
delete pendingEvent;
return;
}
-
- consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
+
event = pendingEvent->getEvent();
if (b == NULL)
}
pendingEvent = (EventRemoveValuePendingEvent *)data;
-
- if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC())
+ consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
+
+ if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC((void*)consumer))
{
LoggerD("private object is garbage collected");
delete pendingEvent;
return;
}
-
- consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
+
event = pendingEvent->getEvent();
if (b == NULL)
}
pendingEvent = (EventUpdateValuePendingEvent *)data;
-
- if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC())
+ consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
+
+ if (DataControlAsyncCallbackManagerSingleton::Instance().isMappedDataControlGC((void*)consumer))
{
LoggerD("private object is garbage collected");
delete pendingEvent;
return;
}
-
- consumer = (MappedDataControlConsumer*)pendingEvent->getThisObject();
+
event = pendingEvent->getEvent();
if (b == NULL)
m_type = type;;
m_dataId = dataId;
m_providerId = provId;
- DataControlAsyncCallbackManagerSingleton::Instance().setMappedDataControlGC(false);
+ DataControlAsyncCallbackManagerSingleton::Instance().setMappedDataControlGC((void*)this, false);
}
MappedDataControlConsumer::~MappedDataControlConsumer()
{
LoggerD("Enter");
- DataControlAsyncCallbackManagerSingleton::Instance().setMappedDataControlGC(true);
+ DataControlAsyncCallbackManagerSingleton::Instance().setMappedDataControlGC((void*)this, true);
}
}
pendingEvent = (EventSelectPendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
-
- if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
+ consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
+
+ if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC((void*)consumer))
{
LoggerD("private object is garbage collected");
delete pendingEvent;
return;
}
-
- consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
event = pendingEvent->getEvent();
std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
}
pendingEvent = (EventInsertPendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
+ consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
- if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
+ if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC((void*)consumer))
{
LoggerD("private object is garbage collected");
delete pendingEvent;
return;
}
-
- consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
+
event = pendingEvent->getEvent();
std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
{
LoggerD("Enter");
- if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
- {
- LoggerD("private object is garbage collected");
- return;
- }
-
EventDeletePendingEvent* pendingEvent = NULL;
SQLDataControlConsumer *consumer = NULL;
EventDeletePtr event;
}
pendingEvent = (EventDeletePendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
+ consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
- if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
+ if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC((void*)consumer))
{
LoggerD("private object is garbage collected");
delete pendingEvent;
return;
}
-
- consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
+
event = pendingEvent->getEvent();
std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
}
pendingEvent = (EventUpdatePendingEvent *)DataControlAsyncCallbackManagerSingleton::Instance().removeSQLUserData(bundleKey);
-
- if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC())
+ consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
+
+ if (DataControlAsyncCallbackManagerSingleton::Instance().isSQLDataControlGC((void*)consumer))
{
LoggerD("private object is garbage collected");
delete pendingEvent;
return;
}
- consumer = (SQLDataControlConsumer*)pendingEvent->getThisObject();
+
event = pendingEvent->getEvent();
std::vector<std::string> result = getDataArrayFromBundle(b, OSP_K_ARG);
m_currentAppId = getCurrentApplicationId();
createResultDir();
- DataControlAsyncCallbackManagerSingleton::Instance().setSQLDataControlGC(false);
+ DataControlAsyncCallbackManagerSingleton::Instance().setSQLDataControlGC((void*)this, false);
}
SQLDataControlConsumer::~SQLDataControlConsumer()
{
LoggerD("Enter");
- DataControlAsyncCallbackManagerSingleton::Instance().setSQLDataControlGC(true);
+ DataControlAsyncCallbackManagerSingleton::Instance().setSQLDataControlGC((void*)this, true);
}
DPL::Mutex SQLDataControlConsumer::m_mutex;
DataSyncManager();
virtual ~DataSyncManager();
+ virtual void addProfile(const IEventAddProfilePtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void updateProfile(const IEventUpdateProfilePtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void removeProfile(const IEventRemoveProfilePtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void getMaxProfilesNum(const IEventGetMaxProfilesNumPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void getProfilesNum(const IEventGetProfilesNumPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void getProfile(const IEventGetProfilePtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void getAllProfiles(const IEventGetAllProfilesPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void startSync(const IEventStartSyncPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void stopSync(const IEventStopSyncPtr &event) {
+ OnRequestReceived(event);
+ }
+
+ virtual void getLastSyncStatistics(const IEventGetLastSyncStatisticsPtr &event) {
+ OnRequestReceived(event);
+ }
+
std::map<std::string, OnDataSyncStateChangedEmitterPtr> m_changeEmitters;
protected:
namespace DataSync {
IDataSyncManager::IDataSyncManager() :
- WrtDeviceApis::Commons::EventRequestReceiver< IEventAddProfile >(WrtDeviceApis::Commons::ThreadEnum::DOWNLOAD_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver< IEventUpdateProfile >(WrtDeviceApis::Commons::ThreadEnum::DOWNLOAD_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver< IEventRemoveProfile >(WrtDeviceApis::Commons::ThreadEnum::DOWNLOAD_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver< IEventGetMaxProfilesNum >(WrtDeviceApis::Commons::ThreadEnum::DOWNLOAD_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver< IEventGetProfilesNum >(WrtDeviceApis::Commons::ThreadEnum::DOWNLOAD_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver< IEventGetProfile >(WrtDeviceApis::Commons::ThreadEnum::DOWNLOAD_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver< IEventGetAllProfiles >(WrtDeviceApis::Commons::ThreadEnum::DOWNLOAD_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver< IEventStartSync >(WrtDeviceApis::Commons::ThreadEnum::DOWNLOAD_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver< IEventStopSync >(WrtDeviceApis::Commons::ThreadEnum::DOWNLOAD_THREAD),
- WrtDeviceApis::Commons::EventRequestReceiver< IEventGetLastSyncStatistics >(WrtDeviceApis::Commons::ThreadEnum::DOWNLOAD_THREAD)
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventAddProfile >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventUpdateProfile >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventRemoveProfile >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventGetMaxProfilesNum >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventGetProfilesNum >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventGetProfile >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventGetAllProfiles >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventStartSync >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventStopSync >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ WrtDeviceApis::Commons::EventRequestReceiver< IEventGetLastSyncStatistics >(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD)
{
}
#include "IPath.h"
#include <Commons/Exception.h>
#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
#include "FilesystemUtils.h"
#include "JSFile.h"
#include "Encodings.h"
break;
}
- JSObjectRef jsObject = JSStorage::createJSObject(context, tmpStorage);
+ JSObjectRef jsObject = JSObjectMake(m_context, NULL, NULL);
+ const ScopedJSStringRef labelStr(JSStringCreateWithUTF8CString("label"));
+ const ScopedJSStringRef typeStr(JSStringCreateWithUTF8CString("type"));
+ const ScopedJSStringRef stateStr(JSStringCreateWithUTF8CString("state"));
+
+ JSObjectSetProperty(m_context, jsObject, labelStr.get(), toJSValueRef(tmpStorage.getLabel()), kJSPropertyAttributeReadOnly, NULL);
+ JSObjectSetProperty(m_context, jsObject, typeStr.get(), toStorageType(tmpStorage.getType()), kJSPropertyAttributeReadOnly, NULL);
+ JSObjectSetProperty(m_context, jsObject, stateStr.get(), toStorageState(tmpStorage.getState()), kJSPropertyAttributeReadOnly, NULL);
+
if (!jsObject) {
ThrowMsg(Commons::ConversionException, "Could not create JS object.");
}
#include "ResponseDispatcher.h"
#include <dpl/assert.h>
-
#include <Commons/Exception.h>
#include <Commons/IEvent.h>
#include <CommonsJavaScript/JSUtils.h>
if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
event->getResult()->setPermissions(data->getPerms());
JSFile::PrivateObjectDefPtr privData(new JSFile::PrivateObjectDef(event->getResult(), JSFile::PrivateObjectDef::PermissionList()));
- INodePtr parent = event->getResult()->getParent();
-
- if (parent)
+ try {
+ INodePtr parent = event->getResult()->getParent();
+
+ if (parent)
+ {
+ privData->pushParentPermissions(data->getPerms());
+ }
+ }
+ catch (...)
{
- privData->pushParentPermissions(data->getPerms());
+ LoggerD("no parent");
}
JSObjectRef object = JSUtils::makeObject(data->getCallbackManager()->getContext(), JSFile::getClassRef(), privData);
}
INdefMessagePtr message = privateObject->getObject();
-
- return message->makeMessage(message->toByte());
+ std::vector<void *> records = toVectorOfRecordHandles(static_cast<JSValueRef>(message->getRecordesPtr()));
+ return message->makeMessage(records);
}
NFCChangedCallback NFCConverter::toNFCChangedCallback(const JSValueRef& arg) {
return JSUtil::toJSValueRef(context, privateData->m_iconPath);
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PACKAGE_INFORMATION_VERSION)) {
return JSUtil::toJSValueRef(context, privateData->m_version);
- } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PACKAGE_INFORMATION_TOTAL_SIZE)) {
- return JSUtil::toJSValueRef(context, privateData->m_totalSize);
- } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PACKAGE_INFORMATION_DATA_SIZE)) {
- return JSUtil::toJSValueRef(context, privateData->m_dataSize);
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PACKAGE_INFORMATION_LAST_MODIFIED)) {
return JSUtil::makeDateObject(context, privateData->m_lastModified);
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PACKAGE_INFORMATION_AUTHOR)) {
return JSUtil::toJSValueRef(context, privateData->m_description);
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PACKAGE_INFORMATION_APP_IDS)) {
return JSUtil::toJSValueRef(context, privateData->m_appIds);
+ } else {
+ // Operation to get size need long time (IPC Delay).
+ if (!privateData->m_isInitialized) {
+ privateData->initializePackageInfo();
+ }
+
+ if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PACKAGE_INFORMATION_TOTAL_SIZE)) {
+ return JSUtil::toJSValueRef(context, privateData->m_totalSize);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_PACKAGE_INFORMATION_DATA_SIZE)) {
+ return JSUtil::toJSValueRef(context, privateData->m_dataSize);
+ }
}
} catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(context, exception, err);
// limitations under the License.
//
+#include <package-manager.h>
+
#include "PackageInformation.h"
+#include <Logger.h>
namespace DeviceAPI {
namespace Package {
-PackageInformation::PackageInformation()
+PackageInformation::PackageInformation() :
+ m_isInitialized(false)
{
}
{
}
+void PackageInformation::initializePackageInfo()
+{
+ LoggerD("Enter : " << m_id);
+
+ pkgmgr_client *pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ LoggerE("Fail to create pkgmgr client");
+ } else {
+ int ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE, pc, NULL, m_id.c_str(), NULL, NULL, NULL);
+ if (ret < 0) {
+ LoggerE("Fail to get total size");
+ } else {
+ m_totalSize = ret;
+ }
+
+ ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, PM_GET_DATA_SIZE, pc, NULL, m_id.c_str(), NULL, NULL, NULL);
+ if (ret < 0) {
+ LoggerE("Fail to get data size");
+ } else {
+ m_dataSize = ret;
+ }
+
+ LoggerD("Before pkgmgr_client_free");
+ pkgmgr_client_free(pc);
+ LoggerD("After pkgmgr_client_free");
+ pc = NULL;
+ }
+
+ m_isInitialized = true;
+}
+
}
}
public:
PackageInformation();
~PackageInformation();
+ void initializePackageInfo();
-// TODO: Should I encapsulate below values?
public:
string m_id;
string m_name;
string m_type;
string m_description;
vector<string> m_appIds;
+ bool m_isInitialized;
};
}
char* name = NULL;
char* iconPath = NULL;
char* version = NULL;
- int totalSize = 0;
- int dataSize = 0;
int lastModified = 0;
char* type = NULL;
char* author = NULL;
pkgInfo->m_version = version;
}
- ret = pkgmgrinfo_pkginfo_get_total_size(handle, &totalSize);
- if (ret != PMINFO_R_OK) {
- LoggerE("Fail to get totalSize");
- } else {
- pkgInfo->m_totalSize = totalSize;
- }
-
- ret = pkgmgrinfo_pkginfo_get_data_size(handle, &dataSize);
- if (ret != PMINFO_R_OK) {
- LoggerE("Fail to get dataSize");
- } else {
- pkgInfo->m_dataSize = dataSize;
- }
-
ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &lastModified);
if (ret != PMINFO_R_OK) {
LoggerE("Fail to get lastModified");
LoggerE("Cannot destroy package info");
}
+ // REMARK: data size and total size is set at first access time
+
// REMARK: do not destroy handle. because handle is comes from outside!!
return pkgInfo;
}
void setExceptionCode(ExceptionCodes::Enumeration exceptionCode);
ExceptionCodes::Enumeration getExceptionCode() const;
+public:
+ pkgmgr_client *pc;
+
private:
vector<PackageInformation> m_pkgInfos;
ExceptionCodes::Enumeration m_exceptionCode;
settingType = converter->toSettingType(arguments[0]);
settingValue = converter->toString(arguments[1]);
- Try{
- DeviceAPI::Filesystem::IPathPtr src = DeviceAPI::Filesystem::Utils::fromVirtualPath(priv->getContext(), settingValue);
- if (src)
- settingValue = src->getFullPath();
- else
- settingValue = ""; //set empty string.
-
- LoggerD("real path = " << settingValue);
- }
- Catch(WrtDeviceApis::Commons::Exception) {
- LoggerD("settingValue is not Virtual Path");
- }
-
LoggerD("settingValue = " << settingValue);
ISystemSettingPtr SystemSettings(priv->getObject());
return JSObjectMake(context, getClassRef(), priv);
}
+JSObjectRef JSTimeDuration::createJSObject(JSContextRef context,
+ const DurationPropertiesPtr duration)
+{
+ TimeDurationPrivObject *priv = new TimeDurationPrivObject(context, duration);
+ if (!priv) {
+ ThrowMsg(NullPointerException, "Private object is null.");
+ }
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
JSObjectRef JSTimeDuration::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
LoggerD("entered");
TimeUtilConverter convert(ctx);
*/
static const JSClassRef getClassRef();
static JSObjectRef createJSObject(JSContextRef context, const DurationProperties &durations);
+ static JSObjectRef createJSObject(JSContextRef context, const DurationPropertiesPtr duration);
static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
private:
return makeDurationObject(duration);
}
+DurationPropertiesPtr TimeUtilConverter::getDuration(JSValueRef value) {
+ if (!JSValueIsObjectOfClass(m_context, value, JSTimeDuration::getClassRef())) {
+ ThrowMsg(Commons::ConversionException, "Wrong duration object.");
+ }
+
+ TimeDurationPrivObject* privateObject = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(toJSObjectRef(value)));
+ DurationPropertiesPtr duration = privateObject->getObject();
+ return duration;
+}
+
DurationProperties TimeUtilConverter::getDurationPropertis(JSValueRef value) {
DurationProperties duration;
duration.length = getDurationLength(value);
TZDateProperties getPropertiesInTZDate(JSObjectRef arg);
JSObjectRef makeDurationObject(const DurationProperties &duration);
JSObjectRef makeMillisecondDurationObject(const long long length);
+ DurationPropertiesPtr getDuration(JSValueRef value);
DurationProperties getDurationPropertis(JSValueRef value);
long long getDurationLength(JSValueRef value);
long long getDurationLength(JSObjectRef object);