X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fmodules%2Ftizen%2FWidget%2FWidget.cpp;h=3bc734175af18d82112292f66fcb3e2e8730e74e;hb=da854ef348cf918993a95adeeffa616db2dca6f7;hp=07cb18b9199aa343b61553e6233dd6f66c510f31;hpb=9c61c076f198660f9d9683fc1f091cbc95b3286b;p=framework%2Fweb%2Fwrt-plugins-common.git diff --git a/src/modules/tizen/Widget/Widget.cpp b/src/modules/tizen/Widget/Widget.cpp index 07cb18b..3bc7341 100644 --- a/src/modules/tizen/Widget/Widget.cpp +++ b/src/modules/tizen/Widget/Widget.cpp @@ -24,7 +24,7 @@ #include #include - +#include #include "Widget.h" #include #include @@ -35,21 +35,23 @@ namespace Widget { using namespace std; using namespace WidgetDB::Api; -Widget::Widget(Commons::IWrtWrapperPtr wrapper) : - m_wrtWrapper(wrapper) +Widget::Widget() +{ + using namespace WrtDeviceApis::Commons; + m_widgetId = WrtAccessSingleton::Instance().getWidgetId(); +} + +Widget::~Widget() { - if (!wrapper) { - LogError("Wrapper is NULL"); - } } string Widget::getProperty(ConfigAttribute attr) const { - checkWrapperPointer(); + checkWidgetId(); string value; Try { - IWidgetDBPtr widgetDB = getWidgetDB(m_wrtWrapper->getWidgetId()); + IWidgetDBPtr widgetDB = getWidgetDB(m_widgetId); value = widgetDB->getConfigValue(attr); } Catch(Commons::InvalidArgumentException){ @@ -62,7 +64,7 @@ string Widget::getProperty(ConfigAttribute attr) const string Widget::getAuthor() const { - checkWrapperPointer(); + checkWidgetId(); if (!m_author.isValid()) { m_author.setValue(getProperty(ConfigAttribute::AUTHOR_NAME)); @@ -72,7 +74,7 @@ string Widget::getAuthor() const string Widget::getAuthorEmail() const { - checkWrapperPointer(); + checkWidgetId(); if (!m_authorEmail.isValid()) { m_authorEmail.setValue(getProperty(ConfigAttribute::AUTHOR_EMAIL)); @@ -82,7 +84,7 @@ string Widget::getAuthorEmail() const string Widget::getAuthorHref() const { - checkWrapperPointer(); + checkWidgetId(); if (!m_authorHref.isValid()) { m_authorHref.setValue(getProperty(ConfigAttribute::AUTHOR_HREF)); @@ -92,7 +94,7 @@ string Widget::getAuthorHref() const string Widget::getDescription() const { - checkWrapperPointer(); + checkWidgetId(); if (!m_description.isValid()) { m_description.setValue(getProperty(ConfigAttribute::DESCRIPTION)); @@ -102,7 +104,7 @@ string Widget::getDescription() const string Widget::getId() const { - checkWrapperPointer(); + checkWidgetId(); LogDebug("entered"); if (!m_id.isValid()) { @@ -113,7 +115,7 @@ string Widget::getId() const string Widget::getName() const { - checkWrapperPointer(); + checkWidgetId(); if (!m_name.isValid()) { m_name.setValue(getProperty(ConfigAttribute::NAME)); @@ -123,7 +125,7 @@ string Widget::getName() const string Widget::getShortName() const { - checkWrapperPointer(); + checkWidgetId(); if (!m_shortName.isValid()) { m_shortName.setValue(getProperty(ConfigAttribute::SHORT_NAME)); @@ -133,7 +135,7 @@ string Widget::getShortName() const string Widget::getVersion() const { - checkWrapperPointer(); + checkWidgetId(); if (!m_version.isValid()) { m_version.setValue(getProperty(ConfigAttribute::VERSION)); @@ -143,7 +145,7 @@ string Widget::getVersion() const unsigned int Widget::getHeight() const { - checkWrapperPointer(); + checkWidgetId(); if (!m_height.isValid()) { m_height.setValue(Commons::String::toInt( @@ -154,7 +156,7 @@ unsigned int Widget::getHeight() const unsigned int Widget::getWidth() const { - checkWrapperPointer(); + checkWidgetId(); if (!m_width.isValid()) { m_width.setValue(Commons::String::toInt( @@ -163,11 +165,11 @@ unsigned int Widget::getWidth() const return m_width.getValue(); } -void Widget::checkWrapperPointer() const +void Widget::checkWidgetId() const { - if (!m_wrtWrapper) { - LogError("Null pointer"); - Throw(Commons::NullPointerException); + if (m_widgetId < 0) { + LogError("Invalid widget id"); + Throw(Commons::InvalidArgumentException); } return; }