Name: wrt-plugins-tizen
Summary: JavaScript plugins for WebRuntime
-Version: 0.4.51
+Version: 0.4.52
Release: 0
Group: Development/Libraries
License: Apache License, Version 2.0
NULL, //ConvertToType
};
-#if 0
-JSStaticValue JSApplication::m_property[] = {
- { TIZEN_APPLICATION_APP_INFO, getProperty, NULL, kJSPropertyAttributeReadOnly },
- { TIZEN_APPLICATION_APP_CONTEXT_ID, getProperty, NULL, kJSPropertyAttributeReadOnly },
- { 0, 0, 0, 0 }
-};
-#endif
-
JSStaticFunction JSApplication::m_function[] = {
{ APPLICATION_FUNCTION_API_EXIT, JSApplication::exit, kJSPropertyAttributeNone },
{ APPLICATION_FUNCTION_API_HIDE, JSApplication::hide, kJSPropertyAttributeNone },
return target;
}
-#if 0
-
-bool JSApplication::isObjectOfClass(JSContextRef context, JSValueRef value)
-{
- return JSValueIsObjectOfClass(context, value, getClassRef());
-}
-
-ApplicationPtr JSApplication::getPrivData(JSObjectRef object)
-{
- JSApplicationPriv *priv = static_cast<JSApplicationPriv*>(JSObjectGetPrivate(object));
- if (!priv) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- ApplicationPtr result = priv->getObject();
- if (!result) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
- }
- return result;
-}
-
-
-JSValueRef JSApplication::getProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
-{
- Try {
- ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
- ApplicationPtr privateData = getPrivData(object);
-
- if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_APP_INFO)) {
- return converter->toJSValueRefFromApplicationInformation(privateData->getAppInfo());
- } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_APP_CONTEXT_ID)) {
- return converter->toJSValueRef(privateData->getContextId());
- }
- } Catch(WrtDeviceApis::Commons::Exception) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- JSWebAPIErrorFactory::postException(context, exception,JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid value error");
- }
-
- return NULL;
-}
-#endif
-
JSValueRef JSApplication::exit(JSContextRef context,
JSObjectRef object,
JSObjectRef thisObject,
*/
static JSClassRef getClassRef();
-/*
- static JSValueRef createJSObject(JSContextRef context,
- const std::string &name,
- const std::string &package,
- const std::string &iconPath,
- const std::string &version,
- const bool &show,
- const std::vector<std::string> &categories,
- const time_t &installDate,
- const long &installSize);
-
- static bool isObjectOfClass(JSContextRef context, JSValueRef value);
-*/
-
-
static JSValueRef makeObject(JSContextRef ctx, const ApplicationPtr value);
-/*
- static ApplicationInformationPtr
- getApplicationInformation(JSContextRef context, JSValueRef value);
-*/
+
/**
* hide the application based on application context.
*/
static JSStaticFunction m_function[];
static JSClassRef m_classRef;
-#if 0
-
- static ApplicationPtr getPrivData(JSObjectRef object);
- static JSValueRef getProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
-#endif
};
}
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CERT_VALUE)) {
return converter.toJSValueRef(privateData->getValue());
}
- } catch (const BasePlatformException &err) {
- return JSWebAPIErrorFactory::postException(context, exception, err);
- } catch (...) {
- DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
- return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ LoggerE("Exception occured while get property");
+ return JSValueMakeUndefined(context);
}
- return JSValueMakeUndefined(context);
+ /* do not return undefined object to find method */
+ return NULL;
}
}
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTEXT_ID)) {
return converter.toJSValueRef(privateData->getContextId());
}
-
- } catch (const BasePlatformException &err) {
- return JSWebAPIErrorFactory::postException(context, exception, err);
- } catch (...) {
- DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
- return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ LoggerE("Exception occured while get property");
+ return JSValueMakeUndefined(context);
}
- return JSValueMakeUndefined(context);
+ /* do not return undefined object to find method */
+ return NULL;
}
return converter->toJSValueRef(appsvc->getAppControlDataArray());
}
- } catch (const BasePlatformException &err) {
- return JSWebAPIErrorFactory::postException(context, exception, err);
} catch (...) {
- DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
- return JSWebAPIErrorFactory::postException(context, exception, err);
+ LoggerE("Exception occured while get property");
+ return JSValueMakeUndefined(context);
}
+
/* do not return undefined object to find method */
return NULL;
}
return true;
}
- } catch (const BasePlatformException &err) {
- return JSWebAPIErrorFactory::postException(context, exception, err);
- } catch (...) {
- DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
- return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ LoggerE("Exception occured while set property");
}
return false;
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_DATA_VALUE)) {
return converter.toJSValueRef(privateData->getValue());
}
- } catch (const BasePlatformException &err) {
- return JSWebAPIErrorFactory::postException(context, exception, err);
- } catch (...) {
- DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
- return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ LoggerE("Exception occured while get property");
+ return JSValueMakeUndefined(context);
}
- return JSValueMakeUndefined(context);
+ /* do not return undefined object to find method */
+ return NULL;
}
+
bool JSApplicationControlData::setProperty(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef value,
JSValueRef* exception)
{
+ const JSValueRef arguments[1] = {value};
+ ArgumentValidator validator(context, 1, arguments);
+
try {
- WrtDeviceApis::CommonsJavaScript::Converter converter(context);
ApplicationControlDataPtr privateData = getPrivData(object);
if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_DATA_KEY)) {
- privateData->setKey(converter.toString(value));
+ privateData->setKey(JSUtil::JSValueToString(context, value));
return true;
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_CONTROL_DATA_VALUE)) {
- privateData->setValue(converter.toVectorOfStrings(value));
+ privateData->setValue(JSUtil::JSArrayToStringVector(context, validator.toArrayObject(0)));
return true;
}
} catch (const BasePlatformException &err) {
- return JSWebAPIErrorFactory::postException(context, exception, err);
- } catch (...) {
- DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
- return JSWebAPIErrorFactory::postException(context, exception, err);
+ LoggerE("Setting property is failed." << err.getMessage());
}
return false;
return converter.toJSValueRefLong(privateData->getInstallSize());
}
}
- } catch (const BasePlatformException &err) {
- return JSWebAPIErrorFactory::postException(context, exception, err);
- } catch (...) {
- DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
- return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ LoggerE("Exception occured while get property");
+ return JSValueMakeUndefined(context);
}
-
- return JSValueMakeUndefined(context);
+
+ /* do not return undefined object to find method */
+ return NULL;
}
}
return converter.toJSValueRef(value);
}
- } catch (const BasePlatformException &err) {
- return JSWebAPIErrorFactory::postException(context, exception, err);
- } catch (...) {
- DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
- return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ LoggerE("Exception occured while get property");
+ return JSValueMakeUndefined(context);
}
- return JSValueMakeUndefined(context);
+ /* do not return undefined object to find method */
+ return NULL;
}
}
{
JSRequestedApplicationControlPriv *priv = static_cast<JSRequestedApplicationControlPriv*>(JSObjectGetPrivate(object));
if (!priv) {
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+ LoggerE("Exception occured while get property");
+ return JSValueMakeUndefined(context);
}
try {
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALLER_APP_ID)) {
return converter->toJSValueRef(providerMgr->getCallerAppId());
}
- } catch (const BasePlatformException &err) {
- LoggerW("Getting property is failed. %s", err.getMessage().c_str());
} catch (...) {
- DeviceAPI::Common::UnknownException err("Unknown Error in RequestedApplicationControl.replyFailure().");
- LoggerW("Getting property is failed. %s", err.getMessage().c_str());
+ LoggerE("Exception occured while get property");
+ return JSValueMakeUndefined(context);
}
/* do not return undefined object to find method */
try {
// Check whether BT is supported or not
bool supported = false;
- if(system_info_get_value_bool(SYSTEM_INFO_KEY_BLUETOOTH_SUPPORTED, &supported) != SYSTEM_INFO_ERROR_NONE) {
+ if(system_info_get_platform_bool("tizen.org/feature/network.bluetooth", &supported) != SYSTEM_INFO_ERROR_NONE) {
LoggerW("Can't check BT is supported or not");
}
}
else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_APPLICATION_ONCONNECT)) {
LoggerD("get onconnect");
- return JSUtil::toJSValueRef(context, priv->mApp->getOnConnect());
+ return priv->mApp->getOnConnect(context);
}
/*
else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_APPLICATION_IS_REGISTERED)) {
RootToPathMapIterator it = rootToPath.find(root);
if (it == rootToPath.end()) {
- //ThrowMsg(Commons::NotFoundException, "Location not found.");
+// ThrowMsg(Commons::NotFoundException, "Location not found.");
LoggerD("Allow non virtual root path " << arg);
return IPath::create(arg);
}
// ThrowMsg(Commons::ConversionException, "Path doesn't contain a valid location type.");
}
+bool DLL_EXPORT isVirtualPath(const std::string& path) {
+ std::string root;
+ std::string::size_type separatorPosition = path.find(IPath::getSeparator());
+
+ if (separatorPosition != std::string::npos) {
+ root = path.substr(0, separatorPosition);
+ } else {
+ root = path;
+ }
+
+ int widgetId = WrtAccessSingleton::Instance().getWidgetId();
+ WidgetDB::Api::IWidgetDBPtr widgetDB = WidgetDB::Api::getWidgetDB(widgetId);
+
+ RootToPathMap rootToPath = getRootToPathMap();
+ rootToPath["wgt-package"] = widgetDB->getWidgetInstallationPath();
+ rootToPath["wgt-private"] = widgetDB->getWidgetPersistentStoragePath();
+ rootToPath["wgt-private-tmp"] = widgetDB->getWidgetTemporaryStoragePath();
+ RootToPathMapIterator it = rootToPath.find(root);
+
+
+ if (it == rootToPath.end()) {
+ return false;
+ }
+ else {
+ return true;
+ }
+}
bool DLL_EXPORT isUriPath(const std::string& path) {
const char* uriPrefix = "file://";
const char* stringFromPath = path.c_str();
bool isPathValid(const std::string& path);
bool isUriPath(const std::string& path);
+bool isVirtualPath(const std::string& path);
void toUTF8String(std::string fromEncoding, const char* from, const size_t fromLength, std::string &outputString);
}
cbm->setObject(thisObject);
IPathPtr path;
- std::string virtualPath;
- path = Utils::fromVirtualPath(globalContext, converter->toString(reserveArguments[0]));
- virtualPath = converter->toString(reserveArguments[0]);
+ std::string virtualPath = converter->toString(reserveArguments[0]);
+
+ if (!Utils::isVirtualPath(virtualPath) && !Utils::isUriPath(virtualPath)) {
+ ThrowMsg(Commons::NotFoundException, "Location not found.");
+ }
+
+ path = Utils::fromVirtualPath(globalContext, virtualPath);
+
LoggerD("virtualPath:[" << virtualPath << "]");
int permissions = PERM_READ | PERM_WRITE;
std::string perm = "rw";
Manager::Locations Manager::m_locations;
Manager::RootList Manager::m_rootlist;
Manager::SubRootList Manager::m_subrootlist;
-const std::size_t Manager::m_maxPathLength = 256;
+const std::size_t Manager::m_maxPathLength = PATH_MAX;
+
NodeList Manager::m_openedNodes;
std::vector<Manager::WatcherPtr> Manager::m_watchers;
struct stat info;
memset(&info, 0, sizeof(struct stat));
int status = lstat(path->getFullPath().c_str(), &info);
- if ((status == 0) || ((status != 0) && (errno != ENOENT))) {
+
+ if (status == 0)
+ {
+ return true;
+ }
+ else if (errno == ENAMETOOLONG)
+ {
+ ThrowMsg(Commons::PlatformException, "file name is too long");
+ }
+ else if (errno != ENOENT)
+ {
return true;
}
return false;
EventMessagingServiceReqReceiver* requestReceiver = mail->getRequestReceiver();
if (mail && requestReceiver) {
EventMessagingServicePtr event = mail->getMessagingServiceEvent();
-// EventMessagingServicePtr event = messagingService->getEventFromHandle(handle);
if ( status == NOTI_DOWNLOAD_BODY_FINISH )
{
event->m_message->readAllData();
+
+ std::vector<IAttachmentPtr> attachments = mail->getAttachments();
+ std::vector<IAttachmentPtr> inlineAttachments = mail->getInlineAttachments();
+
+ for (unsigned int idx = 0; idx < attachments.size() ; idx++ )
+ {
+ LoggerD("set Attachment ID = " << attachments[idx]->getAttachmentID());
+ attachments[idx]->setMessage(event->m_message);
+
+ }
+ for (unsigned int idx = 0; idx < inlineAttachments.size() ; idx++ )
+ {
+ LoggerD("set inline Attachment ID = " << inlineAttachments[idx]->getAttachmentID());
+ inlineAttachments[idx]->setMessage(event->m_message);
+ }
+
requestReceiver->ManualAnswer(event);
m_SyncRequests.erase( handle );
}
#include <Commons/Exception.h>
#include <CommonsJavaScript/Utils.h>
#include <CommonsJavaScript/JSCallbackManager.h>
+#include <JSUtil.h>
#include <JSWebAPIErrorFactory.h>
#include "JSTimeDuration.h"
#include "TimeUtilConverter.h"
}
case DIFFERENCE:
default:
- return converter.makeDurationObject(diff);
+ return converter.makeDurationObject(converter.optimizedTimeDuration(diff));
}
}
return result;
}
+DurationProperties TimeUtilConverter::optimizedTimeDuration(DurationProperties origin) {
+ DurationProperties result;
+ result.unit = origin.unit;
+ result.length = origin.length;
+
+ switch(origin.unit) {
+ case MSECS_UNIT:
+ if (result.length % 1000)
+ return result;
+ result.unit = SECONDS_UNIT;
+ result.length /= 1000;
+ // intentional fall-through
+
+ case SECONDS_UNIT:
+ if (result.length % 60)
+ return result;
+ result.unit = MINUTES_UNIT;
+ result.length /= 60;
+ // intentional fall-through
+
+ case MINUTES_UNIT:
+ if (result.length % 60)
+ return result;
+ result.unit = HOURS_UNIT;
+ result.length /= 60;
+ // intentional fall-through
+
+ case HOURS_UNIT:
+ if (result.length % 24)
+ return result;
+ result.unit = DAYS_UNIT;
+ result.length /= 24;
+ // intentional fall-through
+ }
+ return result;
+}
+
double TimeUtilConverter::getTimeInMilliseconds(JSValueRef arg) {
if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg) || !JSValueIsObjectOfClass(m_context, arg, JSTZDate::getClassRef())) {
ThrowMsg(Commons::ConversionException,
tm toTZDateTime(JSValueRef arg);
tm toTZDateTime(JSObjectRef arg);
JSObjectRef toJSValueRefTZDate(const double milliseconds, const std::string &timezone);
-
+ DurationProperties optimizedTimeDuration(DurationProperties origin);
};
}