#include "WidgetFeature.h"
-
namespace WrtDeviceApis {
namespace WidgetDB {
-
WidgetDB::WidgetDB(int widgetId) : m_widgetId(widgetId) {}
-
int WidgetDB::getWidgetId() const
{
return m_widgetId;
}
// get 'en' language or first from the list if 'en' does not exist
- if (languageTags.size() > 1)
- {
+ if (languageTags.size() > 1) {
FOREACH(lang, languageTags)
{
- if ("en" == DPL::ToUTF8String(*lang))
+ if ("en" == DPL::ToUTF8String(*lang)) {
return "en";
+ }
}
}
- if (!languageTags.empty())
- {
- // get first language tag
+ if (!languageTags.empty()) {
+ // get first language tag
outLanguage = DPL::ToUTF8String(*(languageTags.begin()));
}
return outLanguage;
}
/*License,LicenseHref,Description,Name can be \
- returned with incorect language*/
+ * returned with incorect language*/
std::string WidgetDB::getConfigValue(Api::ConfigAttribute attribute) const
{
LogDebug("entered");
std::ostringstream out;
switch (attribute) {
- case Api::ConfigAttribute::ID: {
+ case Api::ConfigAttribute::ID: {
DPL::OptionalString val = dao.getGUID();
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::VERSION: {
DPL::OptionalString val = dao.getVersion();
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::DESCRIPTION: {
DPL::OptionalString val = widgetInfo.description;
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::LICENSE: {
DPL::OptionalString val = widgetInfo.license;
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::LICENSE_HREF: {
DPL::OptionalString val = widgetInfo.licenseHref;
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::AUTHOR_NAME: {
DPL::OptionalString val = dao.getAuthorName();
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::AUTHOR_EMAIL: {
DPL::OptionalString val = dao.getAuthorEmail();
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::AUTHOR_HREF: {
DPL::OptionalString val = dao.getAuthorHref();
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::NAME: {
DPL::OptionalString val = widgetInfo.name;
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::SHORT_NAME: {
DPL::OptionalString val = widgetInfo.shortName;
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::ACCESS_NETWORK:
value = dao.getAccessNetworkMode() ? "yes" : "no";
DPL::OptionalInt width = dao.getPreferredSize().width;
!width ? out << "0" : out << *width;
value = out.str();
- break; }
+ break;
+ }
case Api::ConfigAttribute::HEIGHT: {
DPL::OptionalInt height = dao.getPreferredSize().height;
!height ? out << "0" : out << *height;
value = out.str();
- break; }
+ break;
+ }
case Api::ConfigAttribute::INSTALL_PATH:
value = DPL::ToUTF8String(dao.getPath());
return value;
}
-
-
std::string WidgetDB::getUserAgent() const
{
- LogDebug("Widget User_Agent data get");
+ LogDebug("Widget User_Agent data get");
- std::string outUA("not implemented");
- return outUA;
+ std::string outUA("not implemented");
+ return outUA;
}
Api::InstallationStatus WidgetDB::checkInstallationStatus(
const std::string& name,
const std::string& version) const
{
- LogDebug("Checking widget ( gid(" << gid << "), name(" << name <<
- "), version(" << version << ")) installation status");
+ LogDebug("Checking widget ( gid(" << gid << "), name(" << name <<
+ "), version(" << version << ")) installation status");
Api::InstallationStatus outStatus;
Try
try {
WrtDB::DbWidgetHandle widgetHandle =
- WrtDB::WidgetDAOReadOnly::getHandle(w_guid);
+ WrtDB::WidgetDAOReadOnly::getHandle(w_guid);
WrtDB::WidgetDAOReadOnly dao(widgetHandle);
DPL::OptionalString ver = dao.getVersion();
} else {
outStatus = Api::InstallationStatus::STATUS_LATEST;
}
- }catch (WrtDB::WidgetDAOReadOnly::Exception::WidgetNotExist) {
+ } catch (WrtDB::WidgetDAOReadOnly::Exception::WidgetNotExist) {
outStatus = Api::InstallationStatus::STATUS_UNINSTALLED;
}
}
return outStatus;
}
-
Api::Features WidgetDB::getWidgetFeatures() const
{
LogDebug("entered");
FOREACH(it, features)
{
Api::IWidgetFeaturePtr feature(
- new WidgetFeature(DPL::ToUTF8String((*it).name),
- (*it).required,
- true)); // requested (WidgetFeature param)
+ new WidgetFeature(DPL::ToUTF8String((*it).name),
+ (*it).required,
+ true)); // requested (WidgetFeature param)
// iterating multimap
FOREACH(iterator, (*it).params)
{
// feature is not on outRegisteredFeature so add it with
// 'required' property false
Api::IWidgetFeaturePtr newFeature(new WidgetFeature(
- dao.GetName(),
- false,
- false));
+ dao.GetName(),
+ false,
+ false));
// TODO what about feature params? aren't they needed
outRegisteredFeatures.push_back(newFeature);
return outRegisteredFeatures;
}
-
std::string WidgetDB::getWidgetInstallationPath() const
{
Try
{
WrtDB::WidgetDAOReadOnly dao(getWidgetId());
std::string result(DPL::ToUTF8String(dao.getFullPath()));
- result.erase(0,strlen("file://"));
+ result.erase(0, strlen("file://"));
std::string::size_type pos = result.size();
std::string separator("/");
pos = result.rfind(separator, pos);
- if((result.size()-pos) >0 && (result.size()-pos) < 2)
- {
+ if ((result.size() - pos) > 0 && (result.size() - pos) < 2) {
result.erase(pos, result.size());
}
- return result;
+ return result;
}
Catch(DPL::Exception)
{
{
WrtDB::WidgetDAOReadOnly dao(getWidgetId());
return
- WrtDB::WidgetConfig::GetWidgetPersistentStoragePath(dao.getTizenPkgId());
+ WrtDB::WidgetConfig::GetWidgetPersistentStoragePath(
+ dao.getTizenPkgId());
}
Catch(DPL::Exception)
{
{
WrtDB::WidgetDAOReadOnly dao(getWidgetId());
return
- WrtDB::WidgetConfig::GetWidgetTemporaryStoragePath(dao.getTizenPkgId());
+ WrtDB::WidgetConfig::GetWidgetTemporaryStoragePath(
+ dao.getTizenPkgId());
}
Catch(DPL::Exception)
{
ReThrow(Commons::PlatformException);
}
}
-
} // WidgetDB
} // WrtDeviceApis