}
namespace WrtDeviceApis {
-
WidgetInterfaceDAO::WidgetInterfaceDAO(int widgetHandle) :
m_widgetHandle(widgetHandle),
m_databaseInterface(databaseFileName(widgetHandle), DATABASE_FLAGS)
std::string databaseFile = databaseFileName(m_widgetHandle);
struct stat buffer;
if (stat(databaseFile.c_str(), &buffer) != 0) {
-
//Create fresh database
LogInfo("Creating database " << databaseFile);
Try
{
DPL::DB::SqlConnection con(databaseFile,
- DATABASE_FLAGS, DATABASE_OPTIONS);
+ DATABASE_FLAGS, DATABASE_OPTIONS);
con.ExecCommand(buffer.str().c_str());
}
Catch(DPL::DB::SqlConnection::Exception::Base)
Equals<Properties::key>(DPL::FromUTF8String(key)));
std::list<Properties::Row> rows = select.GetRowList();
- if (rows.size() == 0) {
+ if (rows.empty()) {
Properties::Insert insert(&m_databaseInterface);
Properties::Row row;
row.Set_key(DPL::FromUTF8String(key));
row.Set_configxml(fromConfigXml ? 1 : 0);
insert.Values(row);
insert.Execute();
- }
- else {
+ } else {
Assert(rows.size() == 1);
Properties::Row row = rows.front();
if (row.Get_readonly() != 0) {
LogError("Cannot set item " << key << " with value " << value);
ReThrow(Commons::PlatformException);
}
-
}
void WidgetInterfaceDAO::removeItem(const std::string& key)
bool readonly = select.GetSingleValue<Properties::readonly>();
if (readonly) {
ThrowMsg(Commons::LocalStorageValueNoModifableException,
- "Cannot delete item. Item is readonly");
+ "Cannot delete item. Item is readonly");
}
Properties::Delete deleteItem(&m_databaseInterface);
deleteItem.Where(Equals<Properties::key>(DPL::FromUTF8String(key)));
}
DPL::Optional<std::string> WidgetInterfaceDAO::getValue(
- const std::string& key) const
+ const std::string& key) const
{
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::widget_interface;
Properties::Select select(&m_databaseInterface);
select.Where(Equals<Properties::key>(DPL::FromUTF8String(key)));
std::list<DPL::String> value = select.GetValueList<Properties::value>();
- if (value.size() == 0) {
+ if (value.empty()) {
return DPL::Optional<std::string>();
}
return DPL::Optional<std::string>(DPL::ToUTF8String(value.front()));
Try
{
WrtDB::WidgetDAOReadOnly widgetDAO(widgetHandle);
- WrtDB::WidgetPkgName pkgname = widgetDAO.getPkgName();
+ WrtDB::TizenPkgId pkgid = widgetDAO.getTizenPkgId();
- filename << GetWidgetPersistentStoragePath(pkgname)
+ filename << GetWidgetPersistentStoragePath(pkgid)
<< "/"
<< GetWidgetInterfaceDatabaseFile();
}
WrtDB::WrtDatabase::detachFromThread();
return filename.str();
}
-
}