#include <cassert>
#include <vector>
-#include <dpl/log.h>
+#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>
#include "JSTizen.h"
#include "JSFeature.h"
#include "plugin_config.h"
+#include <WidgetDB/WidgetDBMgr.h>
+#include <WidgetDB/IWidgetDB.h>
+#include <PluginManager/PluginManagerFactory.h>
#include <iostream>
namespace Tizen1_0 {
namespace Tizen {
+using namespace WrtDeviceApis;
using namespace WrtDeviceApis::Commons;
using namespace TizenApis::Api::Tizen;
+using namespace WrtDeviceApis::PluginManager::Api;
JSClassDefinition JSTizen::m_classInfo =
{
hasProperty,
getProperty,
setProperty,
- deleteProperty,
+ NULL, //deleteProperty,
getPropertyNames,
NULL,
NULL,
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;
- }
- PluginOnDemandPrivPtr privObject(new PluginOnDemandPriv(wrapper));
+ int widgetId = WrtAccessSingleton::Instance().getWidgetId();
+ PluginOnDemandPrivPtr privObject(
+ new PluginOnDemandPriv(
+ PluginManagerFactory::getInstance().getPluginManager(
+ widgetId,
+ PLUGIN_NAME,
+ object,
+ context)));
priv = new TizenPrivate(context, privObject);
if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
return m_classRef;
}
-bool JSTizen::deleteProperty(JSContextRef context, JSObjectRef object,
- JSStringRef propertyName, JSValueRef* exception)
-{
- return true;
-}
+//bool JSTizen::deleteProperty(JSContextRef context, JSObjectRef object,
+// JSStringRef propertyName, JSValueRef* exception)
+//{
+// return true;
+//}
void JSTizen::getPropertyNames(JSContextRef context, JSObjectRef object,
JSPropertyNameAccumulatorRef propertyNames)
{
+ Try
+ {
+ TizenPrivate* priv =
+ static_cast<TizenPrivate*>(JSObjectGetPrivate(object));
+ if (!priv || !priv->getObject()) {
+ LogError("No private obejct");
+ return;
+ }
+ PluginOnDemandPrivPtr privObj = priv->getObject();
+ privObj->getPluginManager()->addPropertiesToList(propertyNames);
+
+ }
+ Catch(Commons::Exception)
+ {
+ LogError("Error occured");
+ }
}
bool JSTizen::hasInstance(JSContextRef context, JSObjectRef constructor,
Try
{
- WrtDeviceApis::CommonsJavaScript::Converter converter(context);
- std::string propName = converter.toString(propertyName);
- LogDebug("checking property:" + propName);
-
- TizenPrivate* priv = static_cast<TizenPrivate*>(JSObjectGetPrivate(object));
+ TizenPrivate* priv = static_cast<TizenPrivate*>(JSObjectGetPrivate(object));
if (!priv || !priv->getObject()) {
LogError("No private obejct");
return false;
}
- PluginOnDemandPrivPtr privObj = priv->getObject();
- PluginOnDemandPriv::ObjectListPtr objList = privObj->getObjectList();
- if (objList->find(propName) != objList->end()) {
- //already set so property exists
- return true;
- }
-
- std::string pluginUri(PLUGIN_NAME);
- pluginUri.append(".").append(propName);
- if (privObj->getWrtWrapper()->isJSObjectAvailable(pluginUri)) {
- LogDebug(propName + " is available");
- //property can be set
- return true;
- }
+ return priv->getObject()->getPluginManager()->hasChild(
+ CommonsJavaScript::Converter(context).toString(propertyName));
}
Catch(WrtDeviceApis::Commons::Exception)
{
Try
{
- WrtDeviceApis::CommonsJavaScript::Converter converter(context);
- std::string propName = converter.toString(propertyName);
-
TizenPrivate* priv =
static_cast<TizenPrivate*>(JSObjectGetPrivate(object));
if (!priv || !priv->getObject()) {
LogError("No private obejct");
return false;
}
- PluginOnDemandPrivPtr privObj = priv->getObject();
- PluginOnDemandPriv::ObjectListPtr objList = privObj->getObjectList();
-
- PluginOnDemandPriv::ObjectList::iterator it = objList->find(propName);
- if (it != objList->end()) {
- //return already set value
- return it->second;
- }
- std::string pluginUri(PLUGIN_NAME);
- pluginUri.append(".").append(propName);
- LogDebug("load new object : " << pluginUri);
- //load new plugin
- privObj->setAllowSettingProperty(true);
- privObj->getWrtWrapper()->loadJSObject(pluginUri);
- privObj->setAllowSettingProperty(false);
- it = objList->find(propName);
- if (it != objList->end()) {
- //return value
- return it->second;
- }
+ return priv->getObject()->getPluginManager()->getProperty(
+ CommonsJavaScript::Converter(context).toString(propertyName));
}
Catch(WrtDeviceApis::Commons::Exception)
{
LogDebug("entered");
Try
{
- WrtDeviceApis::CommonsJavaScript::Converter converter(context);
- std::string propName = converter.toString(propertyName);
-
TizenPrivate* priv =
static_cast<TizenPrivate*>(JSObjectGetPrivate(object));
if (!priv || !priv->getObject()) {
LogError("No private obejct");
return false;
}
- PluginOnDemandPrivPtr privObj = priv->getObject();
-
- std::string pluginUri(PLUGIN_NAME);
- pluginUri.append(".").append(propName);
- if (privObj->getAllowSettingProperty()) {
- JSValueProtect(priv->getContext(), value);
- (*privObj->getObjectList())[propName] = value;
- return true;
- }
+ priv->getObject()->getPluginManager()->setProperty(
+ CommonsJavaScript::Converter(context).toString(propertyName),
+ value);
}
Catch(WrtDeviceApis::Commons::Exception)
{
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);
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);
- IWrtWrapper::Features features = wrapper->getRegisteredFeatures();
+ int widgetId = WrtAccessSingleton::Instance().getWidgetId();
+ WidgetDB::Api::IWidgetDBPtr widgetDB =
+ 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]);
JSObjectRef tempObj = JSObjectMake(context, JSFeature::getClassRef(), 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_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);
- IWrtWrapper::Features features = wrapper->getWidgetFeatures();
+ int widgetId = WrtAccessSingleton::Instance().getWidgetId();
+ WidgetDB::Api::IWidgetDBPtr widgetDB =
+ 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]);
JSObjectRef tempObj = JSObjectMake(context, JSFeature::getClassRef(), priv);