#include <Commons/WrtAccess/WrtAccess.h>
#include <js-overlay/js_iframe_support.h>
-
#define CATCH_EXCEPTION_NO_MODIFABLE \
- Catch(Commons::LocalStorageValueNoModifableException) {\
- LogError("The item is read only");\
- return JSDOMExceptionFactory::\
- NoModificationAllowedException.make(context, exception);\
+ Catch(Commons::LocalStorageValueNoModifableException) { \
+ LogError("The item is read only"); \
+ return JSDOMExceptionFactory:: \
+ NoModificationAllowedException.make(context, exception); \
}
#define CATCH_EXCEPTION_CONVERSION \
- Catch(Commons::ConversionException) {\
- LogError("Error on conversion");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::ConversionException) { \
+ LogError("Error on conversion"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_NULL_PTR \
- Catch(Commons::NullPointerException) {\
- LogError("Error on pointer, null value");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::NullPointerException) { \
+ LogError("Error on pointer, null value"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_PLATFORM_ERROR \
- Catch(Commons::PlatformException){\
- LogError("PlatformException occured");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::PlatformException){ \
+ LogError("PlatformException occured"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_SECURITY \
- Catch(Commons::SecurityException){\
- LogError("Security exception occured");\
- return JSDOMExceptionFactory::\
- SecurityException.make(context, exception);\
+ Catch(Commons::SecurityException){ \
+ LogError("Security exception occured"); \
+ return JSDOMExceptionFactory:: \
+ SecurityException.make(context, exception); \
}
#define CATCH_EXCEPTION_OUT_OF_RANGE \
- Catch(Commons::OutOfRangeException) {\
- LogError("OutOfRangeException");\
- return JSDOMExceptionFactory::\
- QuotaExceededException.make(context, exception);\
+ Catch(Commons::OutOfRangeException) { \
+ LogError("OutOfRangeException"); \
+ return JSDOMExceptionFactory:: \
+ QuotaExceededException.make(context, exception); \
}
#define CATCH_EXCEPTION_INVALID_ARG \
- Catch(Commons::InvalidArgumentException) {\
- LogError("Pair for given key doesnt exist");\
- return JSValueMakeNull(context);\
+ Catch(Commons::InvalidArgumentException) { \
+ LogError("Pair for given key doesnt exist"); \
+ return JSValueMakeNull(context); \
}
#define WIDGET_PLUGIN_NAME "Widget"
namespace WrtPlugins {
namespace W3C {
-
using namespace WrtDeviceApis;
using namespace WrtDeviceApis::Commons;
using namespace WrtDeviceApis::CommonsJavaScript;
using namespace WrtDeviceApis::Widget;
-
struct WidgetPrivateObject
{
Widget::Api::IWidgetPtr iwidget;
typedef std::shared_ptr<WidgetPrivateObject> WidgetPrivateObjectPtr;
typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT
- <WidgetPrivateObjectPtr>::Type JSWidgetPrivateObject;
+<WidgetPrivateObjectPtr>::Type JSWidgetPrivateObject;
WrtDeviceApis::Widget::Api::IWidgetPtr getIWidget(JSObjectRef arg)
{
return priv->getObject()->iwidget;
}
-
LocalStorage::Api::ILocalStoragePtr getLocalStorage(int widgetId)
{
LocalStorage::Api::ILocalStoragePtr storage(
JSPreferences::getClassRef(),
priv);
- if(!preferences){
+ if (!preferences) {
LogError("Preferences object is null");
delete priv;
}
JSValueProtect(context, preferences);
return preferences;
-};
-
+}
JSClassDefinition JSWidget::m_classInfo = {
0,
JSContextRef JSWidget::m_globalContext = NULL;
void JSWidget::initialize(JSContextRef context,
- JSObjectRef object)
+ JSObjectRef object)
{
LogDebug("entered. Context : " << context);
LogDebug("Object: " << object);
createPreferencesObject(context,
object,
widgetId);
- if(!preferences){
+ if (!preferences) {
LogError("Failed to create preferences object");
}
priv = new JSWidgetPrivateObject(context, widgetPriv);
JSObjectSetPrivate(object, priv);
LogDebug("private object created");
-
}
Catch(Commons::InvalidArgumentException){
LogError("You should register widget id in ON_WIDGET_START");
LogError("Failed to create private object for JSWidget");
return;
}
-
}
}
}
void JSWidget::acquireGlobalContext(java_script_context_t global_context,
- js_object_instance_t iframe,
- js_object_instance_t object)
+ js_object_instance_t iframe,
+ js_object_instance_t object)
{
IFrameSupport::RegisterWidget(global_context, iframe, object);
if (!m_globalContext) {
}
JSValueRef JSWidget::getAuthor(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
LogDebug("entered");
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getAuthorEmail(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getAuthorHref(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getDescription(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getId(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getName(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getShortName(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getVersion(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getHeight(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getWidth(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
bool JSWidget::hasProperty(JSContextRef context,
{
LogDebug("enter");
- Try{
+ Try {
Converter converter(context);
std::string key = converter.toString(propertyName);
std::string key = converter.toString(propertyName);
- if (key=="preferences") {
+ if (key == "preferences") {
Converter converter(context);
JSObjectRef pref = getPreferences(object);
- if (!pref)
- {
+ if (!pref) {
LogError("Preferences object is NULL");
return JSValueMakeUndefined(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_INVALID_ARG
+ CATCH_EXCEPTION_INVALID_ARG
}
bool JSWidget::setProperty(JSContextRef context,
{
LogDebug("enter");
- Try{
+ Try {
Converter converter(context);
std::string key = converter.toString(propertyName);
- if (key == "preferences"){
+ if (key == "preferences") {
LogError("Object is read only");
return true;
}
}
CATCH_EXCEPTION_INVALID_ARG
CATCH_EXCEPTION_CONVERSION
- CATCH_EXCEPTION_NULL_PTR
+ CATCH_EXCEPTION_NULL_PTR
return false;
}
LogDebug("widget constructor");
if (!m_globalContext) {
LogError("Global context not set. Creating 'widget' object with "
- "local context!");
+ "local context!");
return JSObjectMake(context, JSWidget::getClassRef(), NULL);
}
return JSObjectMake(m_globalContext, JSWidget::getClassRef(), NULL);
#undef CATCH_EXCEPTION_SECURITY
#undef CATCH_EXCEPTION_OUT_OF_RANGE
#undef CATCH_EXCEPTION_INVALID_ARG
-
}
}