}
}
-void GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::NetworkAccessMode newMode)
-{
- LogDebug("updating home network data usage to:" << newMode);
- Try {
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::wrt;
- GlobalProperties::Row row;
- row.Set_home_network_data_usage(static_cast<int>(newMode));
-
- 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 home network data usage");
- }
-}
-
void GlobalDAO::SetRoamingDataUsage(GlobalDAO::NetworkAccessMode newMode)
{
LogDebug("updating roaming network data usage to:" << newMode);
return select->GetSingleValue<GlobalProperties::secure_by_default>();
}
-GlobalDAOReadOnly::NetworkAccessMode
-GlobalDAOReadOnly::GetHomeNetworkDataUsage()
-{
- LogDebug("Getting home network data usage");
- Try {
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::wrt;
- WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
- return static_cast<GlobalDAOReadOnly::NetworkAccessMode>(
- select->GetSingleValue<
- GlobalProperties::home_network_data_usage>());
- }
- Catch(DPL::DB::SqlConnection::Exception::Base){
- ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
- "Failed to get home network data usage");
- }
-}
-
GlobalDAOReadOnly::NetworkAccessMode GlobalDAOReadOnly::GetRoamingDataUsage()
{
LogDebug("Getting roaming network data usage");
};
/**
- * This method returns network access mode for home network.
- *
- * @return Access mode for home network.
- */
- static NetworkAccessMode GetHomeNetworkDataUsage() DPL_DEPRECATED;
-
- /**
* This method returns network access mode while roaming is enabled.
*
* @return Access mode for home network.
* This method changes network access mode while roaming is enabled.
*
*/
- static void SetHomeNetworkDataUsage(NetworkAccessMode newMode) DPL_DEPRECATED;
-
- /**
- * This method changes network access mode while roaming is enabled.
- *
- */
static void SetRoamingDataUsage(NetworkAccessMode newMode) DPL_DEPRECATED;
static void SetCookieSharingMode(bool mode) DPL_DEPRECATED;
/*TODO: secure_by_default should be 0 by default*/
CREATE_TABLE(GlobalProperties)
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)
COLUMN_NOT_NULL(cookie_sharing_mode, INT, DEFAULT 0)
CREATE_TABLE_END()
RUNNER_TEST_GROUP_INIT(DAO)
/*
- * Name: home_network_data_usage
- * Description: tests if HomeNetworkDataUsage is correctly set and get
- * Expected: received developer shoudl match the one was set
- */
-RUNNER_TEST(home_network_data_usage)
-{
- GlobalDAO::NetworkAccessMode original =
- GlobalDAO::GetHomeNetworkDataUsage();
-
- GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::CONNECT_AUTOMATICALLY);
- RUNNER_ASSERT_MSG(GlobalDAO::CONNECT_AUTOMATICALLY ==
- GlobalDAO::GetHomeNetworkDataUsage(), "Value not updated");
-
- GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::ALWAYS_ASK);
- RUNNER_ASSERT_MSG(GlobalDAO::ALWAYS_ASK ==
- GlobalDAO::GetHomeNetworkDataUsage(), "Value not updated");
-
- GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::NEVER_CONNECT);
- RUNNER_ASSERT_MSG(GlobalDAO::NEVER_CONNECT ==
- GlobalDAO::GetHomeNetworkDataUsage(), "Value not updated");
-
- GlobalDAO::SetHomeNetworkDataUsage(original);
- RUNNER_ASSERT_MSG(original == GlobalDAO::GetHomeNetworkDataUsage(),
- "Value not updated");
-}
-
-/*
* Name: roaming_data_usage
* Description: tests if RoamingDataUsage is correctly set and get
* Expected: received developer shoudl match the one was set