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>
32 namespace WrtDeviceApis {
35 using namespace WidgetDB::Api;
39 using namespace WrtDeviceApis::Commons;
40 m_widgetId = WrtAccessSingleton::Instance().getWidgetId();
46 string Widget::getProperty(ConfigAttribute attr) const
52 IWidgetDBPtr widgetDB = getWidgetDB(m_widgetId);
53 value = widgetDB->getConfigValue(attr);
55 Catch(Commons::InvalidArgumentException){
56 LogError("Invalid argument exception");
57 Throw(Commons::PlatformException);
63 string Widget::getAuthor() const
67 if (!m_author.isValid()) {
68 m_author.setValue(getProperty(ConfigAttribute::AUTHOR_NAME));
70 return m_author.getValue();
73 string Widget::getAuthorEmail() const
77 if (!m_authorEmail.isValid()) {
78 m_authorEmail.setValue(getProperty(ConfigAttribute::AUTHOR_EMAIL));
80 return m_authorEmail.getValue();
83 string Widget::getAuthorHref() const
87 if (!m_authorHref.isValid()) {
88 m_authorHref.setValue(getProperty(ConfigAttribute::AUTHOR_HREF));
90 return m_authorHref.getValue();
93 string Widget::getDescription() const
97 if (!m_description.isValid()) {
98 m_description.setValue(getProperty(ConfigAttribute::DESCRIPTION));
100 return m_description.getValue();
103 string Widget::getId() const
108 if (!m_id.isValid()) {
109 m_id.setValue(getProperty(ConfigAttribute::ID));
111 return m_id.getValue();
114 string Widget::getName() const
118 if (!m_name.isValid()) {
119 m_name.setValue(getProperty(ConfigAttribute::NAME));
121 return m_name.getValue();
124 string Widget::getShortName() const
128 if (!m_shortName.isValid()) {
129 m_shortName.setValue(getProperty(ConfigAttribute::SHORT_NAME));
131 return m_shortName.getValue();
134 string Widget::getVersion() const
138 if (!m_version.isValid()) {
139 m_version.setValue(getProperty(ConfigAttribute::VERSION));
141 return m_version.getValue();
144 unsigned int Widget::getHeight() const
148 if (!m_height.isValid()) {
149 m_height.setValue(Commons::String::convertTo<int>(
150 getProperty(ConfigAttribute::HEIGHT)));
152 return m_height.getValue();
155 unsigned int Widget::getWidth() const
159 if (!m_width.isValid()) {
160 m_width.setValue(Commons::String::convertTo<int>(
161 getProperty(ConfigAttribute::WIDTH)));
163 return m_width.getValue();
166 void Widget::checkWidgetId() const
168 if (m_widgetId < 0) {
169 LogError("Invalid widget id");
170 Throw(Commons::InvalidArgumentException);