namespace WrtDB {
namespace PropertyDAO {
-
+//deprecated
void RemoveProperty(DbWidgetHandle widgetHandle,
const PropertyDAOReadOnly::WidgetPropertyKey &key)
{
+ RemoveProperty(WidgetDAOReadOnly::getPkgName(widgetHandle),key);
+}
+
+void RemoveProperty(WidgetPkgName pkgName,
+ const PropertyDAOReadOnly::WidgetPropertyKey &key)
+{
//TODO below there are two queries.
// First query asks if given property can be removed,
// Second removes it. Maybe it should be combined two one.
- LogDebug("Removing Property. Handle: " << widgetHandle << ", key: " << key);
+ LogDebug("Removing Property. pkgName: " << pkgName << ", key: " << key);
Try {
DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
DPL::OptionalInt readonly = PropertyDAOReadOnly::CheckPropertyReadFlag(
- widgetHandle,
+ pkgName,
key);
if (!readonly.IsNull() && *readonly == 1) {
LogError("'" << key <<
using namespace DPL::DB::ORM::wrt;
WRT_DB_DELETE(del, WidgetPreference, &WrtDatabase::interface())
del->Where(And(
- Equals<WidgetPreference::app_id>(widgetHandle),
+ Equals<WidgetPreference::pkgname>(pkgName),
Equals<WidgetPreference::key_name>(key)));
del->Execute();
}
}
+//deprecated
void SetProperty(DbWidgetHandle widgetHandle,
const PropertyDAOReadOnly::WidgetPropertyKey &key,
const PropertyDAOReadOnly::WidgetPropertyValue &value,
bool readOnly)
{
- LogDebug("Setting/updating Property. Handle: " << widgetHandle <<
+ SetProperty(WidgetDAOReadOnly::getPkgName(widgetHandle),key,value,readOnly);
+}
+
+void SetProperty(WidgetPkgName pkgName,
+ const PropertyDAOReadOnly::WidgetPropertyKey &key,
+ const PropertyDAOReadOnly::WidgetPropertyValue &value,
+ bool readOnly)
+{
+ LogDebug("Setting/updating Property. pkgName: " << pkgName <<
", key: " << key);
Try {
using namespace DPL::DB::ORM;
DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
DPL::OptionalInt readonly = PropertyDAOReadOnly::CheckPropertyReadFlag(
- widgetHandle,
+ pkgName,
key);
if (!readonly.IsNull() && *readonly == 1) {
LogError("'" << key <<
if (readonly.IsNull()) {
WidgetPreference::Row row;
- row.Set_app_id(widgetHandle);
+ row.Set_pkgname(pkgName);
row.Set_key_name(key);
row.Set_key_value(value);
row.Set_readonly(readOnly ? 1 : 0);
WRT_DB_UPDATE(update, WidgetPreference, &WrtDatabase::interface())
update->Where(And(
- Equals<WidgetPreference::app_id>(widgetHandle),
+ Equals<WidgetPreference::pkgname>(pkgName),
Equals<WidgetPreference::key_name>(key)));
update->Values(row);
}
}
+//deprecated
void RegisterProperties(DbWidgetHandle widgetHandle,
const WidgetRegisterInfo ®Info)
{
- LogDebug("Registering proferences for widget. Handle: " << widgetHandle);
+ RegisterProperties(WidgetDAOReadOnly::getPkgName(widgetHandle),regInfo);
+}
+
+void RegisterProperties(WidgetPkgName pkgName,
+ const WidgetRegisterInfo ®Info)
+{
+ LogDebug("Registering proferences for widget. pkgName: " << pkgName);
// Try-Catch in WidgetDAO
{
{ // Insert into table Widget Preferences
WidgetPreference::Row row;
- row.Set_app_id(widgetHandle);
+ row.Set_pkgname(pkgName);
row.Set_key_name(it->name);
row.Set_key_value(it->value);
int readonly = true == it->readonly ? 1 : 0;
*/
#include <stddef.h>
#include <dpl/wrt-dao-ro/property_dao_read_only.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <dpl/log/log.h>
#include <dpl/foreach.h>
#include <dpl/wrt-dao-ro/webruntime_database.h>
FOREACH(it, ormWidgetPrefRow) {
WidgetPreferenceRow row;
- row.app_id = it->Get_app_id();
+ row.pkgname = it->Get_pkgname();
row.key_name = it->Get_key_name();
row.key_value = it->Get_key_value();
row.readonly = it->Get_readonly();
}
+//deprecated
+DPL::OptionalInt CheckPropertyReadFlag(DbWidgetHandle widgetHandle,
+ const WidgetPropertyKey &key)
+{
+ return CheckPropertyReadFlag(WidgetDAOReadOnly::getPkgName(widgetHandle),
+ key);
+}
+
+DPL::OptionalInt CheckPropertyReadFlag(WidgetPkgName pkgName,
+ const WidgetPropertyKey &key)
+{
+ LogDebug("Checking Property flag. pkgName: " << pkgName <<
+ ", key: " << key);
+
+ Try {
+ using namespace DPL::DB::ORM;
+ using namespace DPL::DB::ORM::wrt;
+ WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
+ select->Where(And(Equals<WidgetPreference::pkgname>(pkgName),
+ Equals<WidgetPreference::key_name>(key)));
+
+ return select->GetSingleValue<WidgetPreference::readonly>();
+ }
+ Catch(DPL::DB::SqlConnection::Exception::Base){
+ ReThrowMsg(Exception::DatabaseError,
+ "Failure during checking readonly flag for property");
+ }
+}
+
+//deprecated
WidgetPropertyKeyList GetPropertyKeyList(DbWidgetHandle widgetHandle)
{
- LogDebug("Get PropertyKey list. Handle: " << widgetHandle);
+ return GetPropertyKeyList(WidgetDAOReadOnly::getPkgName(widgetHandle));
+}
+
+WidgetPropertyKeyList GetPropertyKeyList(WidgetPkgName pkgName)
+{
+ LogDebug("Get PropertyKey list. pkgName: " << pkgName);
Try {
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::wrt;
ORMWidgetPropertyKeyList keyList;
WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
- select->Where(Equals<WidgetPreference::app_id>(widgetHandle));
+ select->Where(Equals<WidgetPreference::pkgname>(pkgName));
keyList = select->GetValueList<WidgetPreference::key_name>();
WidgetPropertyKeyList retKeyList;
}
}
+//deprecated
WidgetPreferenceList GetPropertyList(DbWidgetHandle widgetHandle)
{
- LogDebug("Get Property list. Handle: " << widgetHandle);
+ Try{
+ WidgetPkgName pkgName=WidgetDAOReadOnly::getPkgName(widgetHandle);
+ return GetPropertyList(pkgName);
+ }Catch(WidgetDAOReadOnly::Exception::WidgetNotExist){
+ WidgetPreferenceList empty;
+ return empty;
+ }
+}
+
+WidgetPreferenceList GetPropertyList(WidgetPkgName pkgName)
+{
+ LogDebug("Get Property list. pkgName: " << pkgName);
Try {
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::wrt;
WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
- select->Where(Equals<WidgetPreference::app_id>(widgetHandle));
+ select->Where(Equals<WidgetPreference::pkgname>(pkgName));
ORMWidgetPreferenceList ormPrefList = select->GetRowList();
WidgetPreferenceList prefList;
}
}
+//deprecated
WidgetPropertyValue GetPropertyValue(DbWidgetHandle widgetHandle,
const WidgetPropertyKey &key)
{
- LogDebug("Get Property value. Handle: " << widgetHandle <<
+ return GetPropertyValue(WidgetDAOReadOnly::getPkgName(widgetHandle),key);
+}
+
+WidgetPropertyValue GetPropertyValue(WidgetPkgName pkgName,
+ const WidgetPropertyKey &key)
+{
+ LogDebug("Get Property value. pkgName: " << pkgName <<
", key: " << key);
Try {
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::wrt;
WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
- select->Where(And(Equals<WidgetPreference::app_id>(widgetHandle),
+ select->Where(And(Equals<WidgetPreference::pkgname>(pkgName),
Equals<WidgetPreference::key_name>(key)));
ORMWidgetPropertyValue ormPropValue =
}
}
-DPL::OptionalInt CheckPropertyReadFlag(DbWidgetHandle widgetHandle,
- const WidgetPropertyKey &key)
-{
- LogDebug("Checking Property flag. Handle: " << widgetHandle <<
- ", key: " << key);
- Try {
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::wrt;
- WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
- select->Where(And(Equals<WidgetPreference::app_id>(widgetHandle),
- Equals<WidgetPreference::key_name>(key)));
-
- return select->GetSingleValue<WidgetPreference::readonly>();
- }
- Catch(DPL::DB::SqlConnection::Exception::Base){
- ReThrowMsg(Exception::DatabaseError,
- "Failure during checking readonly flag for property");
- }
-}
-
} // namespace PropertyDAOReadOnly
} // namespace WrtDB
const int MAX_TIZENID_LENGTH = 10;
+WidgetPkgName getPkgNameByHandle(const DbWidgetHandle handle)
+{
+ LogDebug("Getting WidgetPkgName by DbWidgetHandle: " << handle);
+
+ SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+ {
+ WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+ select->Where(Equals<WidgetInfo::app_id>(handle));
+ WidgetInfo::Select::RowList rowList = select->GetRowList();
+
+ if (rowList.empty()) {
+ ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+ "Failed to get widget by package name");
+ }
+ DPL::OptionalString pkgname = rowList.front().Get_pkgname();
+ if(pkgname.IsNull()){
+ ThrowMsg(WidgetDAOReadOnly::Exception::DatabaseError,
+ "PkgName is null for this widget");
+ }
+ return *pkgname;
+
+ }
+ SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in getHandle")
+
+ ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+ "Failed to get widget by handle");
+}
} // namespace
"Failed to get widget by package name");
}
+WidgetPkgName WidgetDAOReadOnly::getPkgName() const
+{
+ return getPkgNameByHandle(m_widgetHandle);
+}
+
+WidgetPkgName WidgetDAOReadOnly::getPkgName(const WidgetGUID GUID)
+{
+ return getPkgNameByHandle(getHandle(GUID));
+}
+
+WidgetPkgName WidgetDAOReadOnly::getPkgName(const DbWidgetHandle handle)
+{
+ return getPkgNameByHandle(handle);
+}
+
PropertyDAOReadOnly::WidgetPropertyKeyList
WidgetDAOReadOnly::getPropertyKeyList() const
{
- return PropertyDAOReadOnly::GetPropertyKeyList(m_widgetHandle);
+ return PropertyDAOReadOnly::GetPropertyKeyList(getPkgName());
}
PropertyDAOReadOnly::WidgetPreferenceList
WidgetDAOReadOnly::getPropertyList() const
{
- return PropertyDAOReadOnly::GetPropertyList(m_widgetHandle);
+ return PropertyDAOReadOnly::GetPropertyList(getPkgName());
}
PropertyDAOReadOnly::WidgetPropertyValue WidgetDAOReadOnly::getPropertyValue(
const PropertyDAOReadOnly::WidgetPropertyKey &key) const
{
- return PropertyDAOReadOnly::GetPropertyValue(m_widgetHandle, key);
+ return PropertyDAOReadOnly::GetPropertyValue(getPkgName(), key);
}
DPL::OptionalInt WidgetDAOReadOnly::checkPropertyReadFlag(
const PropertyDAOReadOnly::WidgetPropertyKey &key) const
{
- return PropertyDAOReadOnly::CheckPropertyReadFlag(m_widgetHandle, key);
+ return PropertyDAOReadOnly::CheckPropertyReadFlag(getPkgName(), key);
}
DPL::String WidgetDAOReadOnly::getPath() const
typedef std::list<WidgetPropertyKey> WidgetPropertyKeyList;
struct WidgetPreferenceRow {
- int app_id;
+ WidgetPkgName pkgname;
WidgetPropertyKey key_name;
WidgetPropertyValue key_value;
DPL::OptionalInt readonly;
DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
};
+//deprecated
/* This method checks read only flag for given property
*/
DPL::OptionalInt CheckPropertyReadFlag(DbWidgetHandle widgetHandle,
+ const WidgetPropertyKey &key)
+ __attribute__((deprecated));
+
+/* This method checks read only flag for given property
+ */
+DPL::OptionalInt CheckPropertyReadFlag(WidgetPkgName pkgName,
const WidgetPropertyKey &key);
+//deprecated
/* This method gets widget property key list
*/
-WidgetPropertyKeyList GetPropertyKeyList(DbWidgetHandle widgetHandle);
+WidgetPropertyKeyList GetPropertyKeyList(DbWidgetHandle widgetHandle)
+ __attribute__((deprecated));
+/* This method gets widget property key list
+ */
+WidgetPropertyKeyList GetPropertyKeyList(WidgetPkgName pkgName);
+
+//deprecated
/* This method gets widget property list
*/
-WidgetPreferenceList GetPropertyList(DbWidgetHandle widgetHandle);
+WidgetPreferenceList GetPropertyList(DbWidgetHandle widgetHandle)
+ __attribute__((deprecated));
+/* This method gets widget property list
+ */
+WidgetPreferenceList GetPropertyList(WidgetPkgName pkgName);
+
+//deprecated
/* This method get widget property value
*/
WidgetPropertyValue GetPropertyValue(DbWidgetHandle widgetHandle,
const WidgetPropertyKey &key);
+/* This method get widget property value
+ */
+WidgetPropertyValue GetPropertyValue(WidgetPkgName pkgName,
+ const WidgetPropertyKey &key);
+
} // PropertyDAOReadOnly
} // namespace WrtDB
static DbWidgetHandle getHandle(const DPL::String pkgName);
/**
+ * Returns pkgname for the specified widget
+ *
+ * @return pkgname
+ * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
+ * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
+ */
+ WidgetPkgName getPkgName() const;
+ static WidgetPkgName getPkgName(const WidgetGUID GUID);
+ static WidgetPkgName getPkgName(const DbWidgetHandle handle);
+
+ /**
* This method returns the root directory of widget resource.
*
* @return path name of root directory.
namespace PropertyDAO {
+//deprecated
void RemoveProperty(DbWidgetHandle widgetHandle,
+ const PropertyDAOReadOnly::WidgetPropertyKey &key)
+ __attribute__((deprecated));
+
+void RemoveProperty(WidgetPkgName pkgName,
const PropertyDAOReadOnly::WidgetPropertyKey &key);
+//deprecated
/* This method sets widget property
*/
void SetProperty(DbWidgetHandle widgetHandle,
const PropertyDAOReadOnly::WidgetPropertyKey &key,
const PropertyDAOReadOnly::WidgetPropertyValue &value,
+ bool readOnly = false)
+ __attribute__((deprecated));
+
+/* This method sets widget property
+ */
+void SetProperty(WidgetPkgName pkgName,
+ const PropertyDAOReadOnly::WidgetPropertyKey &key,
+ const PropertyDAOReadOnly::WidgetPropertyValue &value,
bool readOnly = false);
+//deprecated
/* This method registers properties for widget.
* Properties unregistering is done via "delete cascade" mechanism in SQL
*/
void RegisterProperties(DbWidgetHandle widgetHandle,
+ const WidgetRegisterInfo ®Info)
+ __attribute__((deprecated));
+
+/* This method registers properties for widget.
+ * Properties unregistering is done via "delete cascade" mechanism in SQL
+ */
+void RegisterProperties(WidgetPkgName pkgName,
const WidgetRegisterInfo ®Info);
} // namespace PropertyDAO
CREATE_TABLE_END()
CREATE_TABLE(WidgetPreference)
- COLUMN_NOT_NULL(app_id, INT,)
+ COLUMN_NOT_NULL(pkgname, VARCHAR(256), DEFAULT 0)
COLUMN_NOT_NULL(key_name, VARCHAR(256),)
COLUMN(key_value, VARCHAR(8000), DEFAULT '')
COLUMN(readonly, INT, DEFAULT 0)
TABLE_CONSTRAINTS(
- PRIMARY KEY(app_id, key_name),
- FOREIGN KEY(app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
+ PRIMARY KEY(pkgname, key_name),
+ FOREIGN KEY(pkgname) REFERENCES WidgetInfo (pkgname) ON DELETE CASCADE
)
CREATE_TABLE_END()