2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
25 #include <dpl/log/log.h>
26 #include <Commons/StringUtils.h>
27 #include <Commons/WrtAccess/WrtAccess.h>
29 #include <WidgetDB/IWidgetDB.h>
30 #include <WidgetDB/WidgetDBMgr.h>
33 namespace WrtDeviceApis {
36 using namespace WidgetDB::Api;
40 using namespace WrtDeviceApis::Commons;
41 m_widgetId = WrtAccessSingleton::Instance().getWidgetId();
48 string Widget::getProperty(ConfigAttribute attr) const
54 IWidgetDBPtr widgetDB = getWidgetDB(m_widgetId);
55 value = widgetDB->getConfigValue(attr);
57 Catch(Commons::InvalidArgumentException){
58 LogError("Invalid argument exception");
59 Throw(Commons::PlatformException);
65 string Widget::getAuthor() const
69 if (!m_author.isValid()) {
70 m_author.setValue(getProperty(ConfigAttribute::AUTHOR_NAME));
72 return m_author.getValue();
75 string Widget::getAuthorEmail() const
79 if (!m_authorEmail.isValid()) {
80 m_authorEmail.setValue(getProperty(ConfigAttribute::AUTHOR_EMAIL));
82 return m_authorEmail.getValue();
85 string Widget::getAuthorHref() const
89 if (!m_authorHref.isValid()) {
90 m_authorHref.setValue(getProperty(ConfigAttribute::AUTHOR_HREF));
92 return m_authorHref.getValue();
95 string Widget::getDescription() const
99 if (!m_description.isValid()) {
100 m_description.setValue(getProperty(ConfigAttribute::DESCRIPTION));
102 return m_description.getValue();
105 string Widget::getId() const
110 if (!m_id.isValid()) {
111 m_id.setValue(getProperty(ConfigAttribute::ID));
113 return m_id.getValue();
116 string Widget::getName() const
120 if (!m_name.isValid()) {
121 m_name.setValue(getProperty(ConfigAttribute::NAME));
123 return m_name.getValue();
126 string Widget::getShortName() const
130 if (!m_shortName.isValid()) {
131 m_shortName.setValue(getProperty(ConfigAttribute::SHORT_NAME));
133 return m_shortName.getValue();
136 string Widget::getVersion() const
140 if (!m_version.isValid()) {
141 m_version.setValue(getProperty(ConfigAttribute::VERSION));
143 return m_version.getValue();
146 unsigned int Widget::getHeight() const
150 if (!m_height.isValid()) {
151 m_height.setValue(Commons::String::toInt(
152 getProperty(ConfigAttribute::HEIGHT)));
154 return m_height.getValue();
157 unsigned int Widget::getWidth() const
161 if (!m_width.isValid()) {
162 m_width.setValue(Commons::String::toInt(
163 getProperty(ConfigAttribute::WIDTH)));
165 return m_width.getValue();
168 void Widget::checkWidgetId() const
170 if (m_widgetId < 0) {
171 LogError("Invalid widget id");
172 Throw(Commons::InvalidArgumentException);