f9c703cdaafb410a43648b68dfb4f7e928d00861
[platform/framework/web/wrt.git] / src / global_logic / global_model.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /*
17  * @file        global_model.cpp
18  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
19  */
20 #include "global_model.h"
21 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
22
23 using namespace WrtDB;
24
25 GlobalModel::GlobalModel() :
26     HomeNetworkAccess(this,
27         & GlobalModel::HomeNetworkAccessReadProperty),
28     RoamingNetworkAccess(this,
29         & GlobalModel::RoamingNetworkAccessReadProperty),
30     DeveloperMode(this,
31         static_cast<DPL::Event::Property<bool,
32                         DPL::Event::PropertyReadOnly,
33                         DPL::Event::PropertyStorageDynamicCached>::ReadDelegateType>
34                         (& GlobalModel::ReadDeveloperMode))
35 {
36 }
37
38 GlobalModel::NetworkAccessMode GlobalModel::HomeNetworkAccessReadProperty(
39         DPL::Event::Model* /*model*/)
40 {
41     switch (GlobalDAOReadOnly::GetHomeNetworkDataUsage()) {
42     case GlobalDAOReadOnly::NEVER_CONNECT:
43         return GlobalModel::NEVER_CONNECT;
44     case GlobalDAOReadOnly::ALWAYS_ASK:
45         return GlobalModel::ALWAYS_ASK;
46     case GlobalDAOReadOnly::CONNECT_AUTOMATICALLY:
47         return GlobalModel::CONNECT_AUTOMATICALLY;
48     default:
49         break;
50     }
51     LogWarning("using default value");
52     return GlobalModel::ALWAYS_ASK;
53 }
54
55 GlobalModel::NetworkAccessMode GlobalModel::RoamingNetworkAccessReadProperty(
56         DPL::Event::Model* /*model*/)
57 {
58     switch (GlobalDAOReadOnly::GetRoamingDataUsage()) {
59     case GlobalDAOReadOnly::NEVER_CONNECT:
60         return GlobalModel::NEVER_CONNECT;
61     case GlobalDAOReadOnly::ALWAYS_ASK:
62         return GlobalModel::ALWAYS_ASK;
63     case GlobalDAOReadOnly::CONNECT_AUTOMATICALLY:
64         return GlobalModel::CONNECT_AUTOMATICALLY;
65     default:
66         break;
67     }
68     LogWarning("using default value");
69     return GlobalModel::ALWAYS_ASK;
70 }
71
72 bool GlobalModel::ReadDeveloperMode(DPL::Event::Model */*model*/)
73 {
74     return GlobalDAOReadOnly::GetDeveloperMode();
75 }