upload tizen1.0 source
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Tizen / JSTizen.cpp
index 51e7803..2745cd1 100755 (executable)
@@ -26,8 +26,7 @@
 #include <dpl/log/log.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Converter.h>
-#include <Commons/WrtWrapper/IWrtWrapper.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include <API/Filter/FilterTypes.h>
 #include <API/Filter/AnyType.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
@@ -99,24 +98,14 @@ void JSTizen::initialize(JSContextRef context, JSObjectRef object)
     if (priv) {
         delete priv;
     }
-    IWrtWrapperPtr wrapper;
-    Try
-    {
-        wrapper = WrtWrappersMgr::getInstance().getWrtWrapper(context);
-    }
-    Catch(WrtDeviceApis::Commons::InvalidArgumentException)
-    {
-        LogError("Cannot get WRT wrapper.");
-        LogError("You should register your wrapper in ON_WIDGET_START");
-        return;
-    }
 
+    int widgetId = WrtAccessSingleton::Instance().getWidgetId();
     PluginOnDemandPrivPtr privObject(
         new PluginOnDemandPriv(
-            wrapper,
                        PluginManagerFactory::getInstance().getPluginManager(
-                           wrapper->getWidgetId(),
+                           widgetId,
                            PLUGIN_NAME,
+                           object,
                            context)));
 
     priv = new TizenPrivate(context, privObject);
@@ -266,14 +255,13 @@ JSValueRef JSTizen::listAvailableFeatures(JSContextRef context, JSObjectRef obje
         const JSValueRef arguments[], JSValueRef* exception)
 {
     LogDebug("entered");
-    IWrtWrapperPtr wrapper;
 
     TizenPrivate* priv = static_cast<TizenPrivate*>(JSObjectGetPrivate(thisObject));
     assert(priv);
 
     /*
      * Current Tizen spec assures that tizen is always available
-    AccessStatus status = DEVICEAPIS_CHECK_ACCESS(priv->getContext(),
+    AccessStatus status = DEVICEAPIS_CHECK_ACCESS(
                                  DEVICEAPIS_FUNCTION_API_LIST_AVAIL_FEATURES);
 
     SYNC_ACCESS_STATUS_HANDLER(status, context, exception);
@@ -284,18 +272,16 @@ JSValueRef JSTizen::listAvailableFeatures(JSContextRef context, JSObjectRef obje
         if (!priv) {
             ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "No private object");
         }
-//        wrapper = priv->getObject();
            PluginOnDemandPrivPtr privObj = priv->getObject();
-           wrapper = privObj->getWrtWrapper();
     }
     catch(const WrtDeviceApis::Commons::Exception &ex)
     {
-        LogError("couldn't get wrapper, " << ex.GetMessage());
         return WrtDeviceApis::CommonsJavaScript::JSDOMExceptionFactory::UnknownException.make(context, exception);
     }
     JSObjectRef result = JSCreateArrayObject(context, 0, NULL);
+    int widgetId = WrtAccessSingleton::Instance().getWidgetId();
     WidgetDB::Api::IWidgetDBPtr widgetDB =
-        WidgetDB::Api::getWidgetDB(wrapper->getWidgetId());
+        WidgetDB::Api::getWidgetDB(widgetId);
     WidgetDB::Api::Features features = widgetDB->getRegisteredFeatures();
     for (size_t i=0; i<features.size(); ++i) {
         JSFeaturePrivateObject *priv = new JSFeaturePrivateObject(context, features[i]);
@@ -323,27 +309,25 @@ JSValueRef JSTizen::listActivatedFeatures(JSContextRef context, JSObjectRef obje
 
     /*
      * Current Tizen spec assures that tizen is always available
-     AccessStatus status = DEVICEAPIS_CHECK_ACCESS(priv->getContext(),
+     AccessStatus status = DEVICEAPIS_CHECK_ACCESS(
                                  DEVICEAPIS_FUNCTION_API_LIST_ACTIV_FEATURES);
 
     SYNC_ACCESS_STATUS_HANDLER(status, context, exception);*/
-    IWrtWrapperPtr wrapper;
     try
     {
         if (!priv) {
             ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "No private object");
         }
         PluginOnDemandPrivPtr privObj = priv->getObject();
-        wrapper = privObj->getWrtWrapper();
     }
     catch(const WrtDeviceApis::Commons::Exception &ex)
     {
-        LogError("couldn't get wrapper, " << ex.GetMessage());
         return WrtDeviceApis::CommonsJavaScript::JSDOMExceptionFactory::UnknownException.make(context, exception);
     }
     JSObjectRef result = JSCreateArrayObject(context, 0, NULL);
+    int widgetId = WrtAccessSingleton::Instance().getWidgetId();
     WidgetDB::Api::IWidgetDBPtr widgetDB =
-        WidgetDB::Api::getWidgetDB(wrapper->getWidgetId());
+        WidgetDB::Api::getWidgetDB(widgetId);
     WidgetDB::Api::Features features = widgetDB->getWidgetFeatures();
     for (size_t i=0; i<features.size(); ++i) {
         JSFeaturePrivateObject *priv = new JSFeaturePrivateObject(context, features[i]);