ce3ad9d76212ab4bda393f913782b294629fb0d7
[platform/framework/native/telephony.git] / src / FTelNetworkStatus.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file        FTelNetworkStatus.cpp
19  * @brief       This is the implementation file for NetworkStatus class.
20  */
21
22 #include <FTelNetworkStatus.h>
23 #include <FBaseSysLog.h>
24 #include <FSec_AccessController.h>
25 #include "FTel_NetworkStatusImpl.h"
26
27 using namespace Tizen::Security;
28
29 namespace Tizen { namespace Telephony
30 {
31 NetworkStatus::NetworkStatus(void)
32         : __pNetworkStatusImpl(null)
33 {
34         __pNetworkStatusImpl = new (std::nothrow) _NetworkStatusImpl();
35         SysTryReturnVoidResult(NID_TEL, __pNetworkStatusImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
36 }
37
38 NetworkStatus::~NetworkStatus(void)
39 {
40         delete __pNetworkStatusImpl;
41 }
42
43 bool
44 NetworkStatus::IsRoaming(void) const
45 {
46         ClearLastResult();
47
48         result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
49         SysTryReturn(NID_TEL, r == E_SUCCESS, false, E_PRIVILEGE_DENIED,
50                 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
51
52         bool isRoaming = false;
53
54         isRoaming = __pNetworkStatusImpl->IsRoaming();
55
56         return isRoaming;
57 }
58
59 bool
60 NetworkStatus::IsCallServiceAvailable(void) const
61 {
62         ClearLastResult();
63
64         result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
65         SysTryReturn(NID_TEL, r == E_SUCCESS, false, E_PRIVILEGE_DENIED,
66                 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
67
68         bool isCallServiceAvailable = false;
69
70         isCallServiceAvailable = __pNetworkStatusImpl->IsCallServiceAvailable();
71
72         return isCallServiceAvailable;
73 }
74
75 bool
76 NetworkStatus::IsDataServiceAvailable(void) const
77 {
78         ClearLastResult();
79
80         result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
81         SysTryReturn(NID_TEL, r == E_SUCCESS, false, E_PRIVILEGE_DENIED,
82                 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
83
84         bool isDataServiceAvailable = false;
85
86         isDataServiceAvailable = __pNetworkStatusImpl->IsDataServiceAvailable();
87
88         return isDataServiceAvailable;
89 }
90
91 }} // Tizen::Telephony