#include <dpl/wrt-dao-ro/WrtDatabase.h>
namespace WrtDB {
-void GlobalDAO::SetDeveloperMode(bool mode)
-{
- LogDebug("updating Developer mode to:" << mode);
- Try {
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::wrt;
- GlobalProperties::Row row;
- row.Set_developer_mode(mode);
-
- WRT_DB_UPDATE(update, GlobalProperties, &WrtDatabase::interface())
- update->Values(row);
- update->Execute();
- }
- Catch(DPL::DB::SqlConnection::Exception::Base){
- ReThrowMsg(GlobalDAO::Exception::DatabaseError,
- "Failed to update Developer Mode");
- }
-}
-
void GlobalDAO::SetSecureByDefault(bool secure)
{
//If secure == true -> widget does not need to be signed
#include <dpl/wrt-dao-ro/common_dao_types.h>
namespace WrtDB {
-bool GlobalDAOReadOnly::GetDeveloperMode()
-{
- LogDebug("Getting Developer mode");
- Try {
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::wrt;
- WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
- return select->GetSingleValue<GlobalProperties::developer_mode>();
- }
- Catch(DPL::DB::SqlConnection::Exception::Base){
- ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
- "Failed to get developer mode");
- }
-}
bool GlobalDAOReadOnly::GetSecureByDefault()
{
static bool IsValidSubTag(const DPL::String& tag, int type);
- static bool GetDeveloperMode();
-
static bool GetSecureByDefault();
static bool getComplianceMode();
class GlobalDAO : public GlobalDAOReadOnly
{
public:
- static void SetDeveloperMode(bool mode);
-
static void SetSecureByDefault(bool secureByDefault);
static void setComplianceMode(bool mode);
)
/*TODO: secure_by_default should be 0 by default*/
CREATE_TABLE(GlobalProperties)
- COLUMN_NOT_NULL(developer_mode, INT, DEFAULT 0)
COLUMN_NOT_NULL(secure_by_default, INT, DEFAULT 1)
COLUMN_NOT_NULL(home_network_data_usage, TINYINT, DEFAULT 1)
COLUMN_NOT_NULL(roaming_data_usage, TINYINT, DEFAULT 1)
RUNNER_TEST_GROUP_INIT(DAO)
/*
- * Name: global_dao_developer_mode
- * Description: tests if developer mode is correctly set and get
- * Expected: received developer shoudl match the one was set
- */
-RUNNER_TEST(global_dao_developer_mode)
-{
- bool prev_mode = GlobalDAO::GetDeveloperMode();
- GlobalDAO::SetDeveloperMode(false);
- RUNNER_ASSERT_MSG(!GlobalDAO::GetDeveloperMode(), "set false failed");
-
- GlobalDAO::SetDeveloperMode(true);
- RUNNER_ASSERT_MSG(GlobalDAO::GetDeveloperMode(), "set true failed");
- GlobalDAO::SetDeveloperMode(prev_mode);
-}
-
-/*
* Name: home_network_data_usage
* Description: tests if HomeNetworkDataUsage is correctly set and get
* Expected: received developer shoudl match the one was set