#include <dpl/log/log.h>
#include <Commons/StringUtils.h>
-
+#include <Commons/WrtAccess/WrtAccess.h>
#include "Widget.h"
#include <WidgetDB/IWidgetDB.h>
#include <WidgetDB/WidgetDBMgr.h>
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){
string Widget::getAuthor() const
{
- checkWrapperPointer();
+ checkWidgetId();
if (!m_author.isValid()) {
m_author.setValue(getProperty(ConfigAttribute::AUTHOR_NAME));
string Widget::getAuthorEmail() const
{
- checkWrapperPointer();
+ checkWidgetId();
if (!m_authorEmail.isValid()) {
m_authorEmail.setValue(getProperty(ConfigAttribute::AUTHOR_EMAIL));
string Widget::getAuthorHref() const
{
- checkWrapperPointer();
+ checkWidgetId();
if (!m_authorHref.isValid()) {
m_authorHref.setValue(getProperty(ConfigAttribute::AUTHOR_HREF));
string Widget::getDescription() const
{
- checkWrapperPointer();
+ checkWidgetId();
if (!m_description.isValid()) {
m_description.setValue(getProperty(ConfigAttribute::DESCRIPTION));
string Widget::getId() const
{
- checkWrapperPointer();
+ checkWidgetId();
LogDebug("entered");
if (!m_id.isValid()) {
string Widget::getName() const
{
- checkWrapperPointer();
+ checkWidgetId();
if (!m_name.isValid()) {
m_name.setValue(getProperty(ConfigAttribute::NAME));
string Widget::getShortName() const
{
- checkWrapperPointer();
+ checkWidgetId();
if (!m_shortName.isValid()) {
m_shortName.setValue(getProperty(ConfigAttribute::SHORT_NAME));
string Widget::getVersion() const
{
- checkWrapperPointer();
+ checkWidgetId();
if (!m_version.isValid()) {
m_version.setValue(getProperty(ConfigAttribute::VERSION));
unsigned int Widget::getHeight() const
{
- checkWrapperPointer();
+ checkWidgetId();
if (!m_height.isValid()) {
m_height.setValue(Commons::String::toInt(
unsigned int Widget::getWidth() const
{
- checkWrapperPointer();
+ checkWidgetId();
if (!m_width.isValid()) {
m_width.setValue(Commons::String::toInt(
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;
}