Source code formating unification
[platform/framework/web/wrt-plugins-common.git] / src / standards / W3C / Widget / JSWidget.cpp
index 9daec95..9531cef 100644 (file)
 #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;
@@ -115,7 +112,7 @@ struct WidgetPrivateObject
 typedef std::shared_ptr<WidgetPrivateObject> WidgetPrivateObjectPtr;
 
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT
-    <WidgetPrivateObjectPtr>::Type JSWidgetPrivateObject;
+<WidgetPrivateObjectPtr>::Type JSWidgetPrivateObject;
 
 WrtDeviceApis::Widget::Api::IWidgetPtr getIWidget(JSObjectRef arg)
 {
@@ -131,7 +128,6 @@ WrtDeviceApis::Widget::Api::IWidgetPtr getIWidget(JSObjectRef arg)
     return priv->getObject()->iwidget;
 }
 
-
 LocalStorage::Api::ILocalStoragePtr getLocalStorage(int widgetId)
 {
     LocalStorage::Api::ILocalStoragePtr storage(
@@ -168,7 +164,7 @@ JSObjectRef createPreferencesObject(JSContextRef context,
                                            JSPreferences::getClassRef(),
                                            priv);
 
-    if(!preferences){
+    if (!preferences) {
         LogError("Preferences object is null");
         delete priv;
     }
@@ -176,8 +172,7 @@ JSObjectRef createPreferencesObject(JSContextRef context,
     JSValueProtect(context, preferences);
 
     return preferences;
-};
-
+}
 
 JSClassDefinition JSWidget::m_classInfo = {
     0,
@@ -241,7 +236,7 @@ JSClassRef JSWidget::m_jsClassRef = JSClassCreate(JSWidget::getClassInfo());
 JSContextRef JSWidget::m_globalContext = NULL;
 
 void JSWidget::initialize(JSContextRef context,
-        JSObjectRef object)
+                          JSObjectRef object)
 {
     LogDebug("entered. Context : " << context);
     LogDebug("Object: " << object);
@@ -262,7 +257,7 @@ void JSWidget::initialize(JSContextRef context,
                 createPreferencesObject(context,
                                         object,
                                         widgetId);
-            if(!preferences){
+            if (!preferences) {
                 LogError("Failed to create preferences object");
             }
 
@@ -273,7 +268,6 @@ void JSWidget::initialize(JSContextRef context,
             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");
@@ -283,7 +277,6 @@ void JSWidget::initialize(JSContextRef context,
             LogError("Failed to create private object for JSWidget");
             return;
         }
-
     }
 }
 
@@ -306,8 +299,8 @@ void JSWidget::finalize(JSObjectRef object)
 }
 
 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) {
@@ -319,9 +312,9 @@ void JSWidget::acquireGlobalContext(java_script_context_t global_context,
 }
 
 JSValueRef JSWidget::getAuthor(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
+                               JSObjectRef object,
+                               JSStringRef propertyName,
+                               JSValueRef* exception)
 {
     LogDebug("entered");
 
@@ -331,13 +324,13 @@ JSValueRef JSWidget::getAuthor(JSContextRef context,
     }
     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);
@@ -345,13 +338,13 @@ JSValueRef JSWidget::getAuthorEmail(JSContextRef 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);
@@ -359,13 +352,13 @@ JSValueRef JSWidget::getAuthorHref(JSContextRef 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);
@@ -373,13 +366,13 @@ JSValueRef JSWidget::getDescription(JSContextRef 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);
@@ -387,13 +380,13 @@ JSValueRef JSWidget::getId(JSContextRef 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);
@@ -401,13 +394,13 @@ JSValueRef JSWidget::getName(JSContextRef 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);
@@ -415,13 +408,13 @@ JSValueRef JSWidget::getShortName(JSContextRef 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);
@@ -429,13 +422,13 @@ JSValueRef JSWidget::getVersion(JSContextRef 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);
@@ -447,13 +440,13 @@ JSValueRef JSWidget::getHeight(JSContextRef 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);
@@ -465,7 +458,7 @@ JSValueRef JSWidget::getWidth(JSContextRef context,
     }
     CATCH_EXCEPTION_CONVERSION
     CATCH_EXCEPTION_NULL_PTR
-    CATCH_EXCEPTION_PLATFORM_ERROR
+        CATCH_EXCEPTION_PLATFORM_ERROR
 }
 
 bool JSWidget::hasProperty(JSContextRef context,
@@ -474,7 +467,7 @@ bool JSWidget::hasProperty(JSContextRef context,
 {
     LogDebug("enter");
 
-    Try{
+    Try {
         Converter converter(context);
 
         std::string key = converter.toString(propertyName);
@@ -512,11 +505,10 @@ JSValueRef JSWidget::getProperty(JSContextRef context,
 
         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);
             }
@@ -528,7 +520,7 @@ JSValueRef JSWidget::getProperty(JSContextRef context,
 
     CATCH_EXCEPTION_CONVERSION
     CATCH_EXCEPTION_NULL_PTR
-    CATCH_EXCEPTION_INVALID_ARG
+        CATCH_EXCEPTION_INVALID_ARG
 }
 
 bool JSWidget::setProperty(JSContextRef context,
@@ -539,18 +531,18 @@ 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;
 }
@@ -564,7 +556,7 @@ JSObjectRef JSWidget::callAsConstructor(JSContextRef context,
     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);
@@ -577,6 +569,5 @@ JSObjectRef JSWidget::callAsConstructor(JSContextRef context,
 #undef CATCH_EXCEPTION_SECURITY
 #undef CATCH_EXCEPTION_OUT_OF_RANGE
 #undef CATCH_EXCEPTION_INVALID_ARG
-
 }
 }