2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FNetNetStatistics.cpp
19 * @brief This is the implementation for the FNetNetStatistics class.
22 #include <unique_ptr.h>
23 #include <FNetNetTypes.h>
24 #include <FNetNetStatistics.h>
25 #include <FNet_NetTypes.h>
26 #include <FBaseSysLog.h>
27 #include <FSec_AccessController.h>
28 #include "FNet_NetStatisticsImpl.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Security;
34 namespace Tizen { namespace Net
37 NetStatistics::NetStatistics(void)
38 : __pNetStatisticsImpl(null)
43 NetStatistics::Construct(void)
47 SysAssertf(__pNetStatisticsImpl == null,
48 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
50 unique_ptr<_NetStatisticsImpl> pNetStatisticsImpl(new (std::nothrow) _NetStatisticsImpl());
51 SysTryReturnResult(NID_NET, pNetStatisticsImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
53 r = pNetStatisticsImpl->Construct();
54 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
56 __pNetStatisticsImpl = pNetStatisticsImpl.release();
61 NetStatistics::~NetStatistics(void)
63 delete __pNetStatisticsImpl;
64 __pNetStatisticsImpl = null;
68 NetStatistics::GetNetStatisticsInfo(NetBearerType operationMode, NetStatisticsInfoType netStatType) const
71 long long ret = INVALID_HANDLE;
75 r = _AccessController::CheckUserPrivilege(_PRV_NETWORK_STATISTICS_READ, _PRV_NETWORK_STATISTICS);
76 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
77 SysTryReturn(NID_NET, r == E_SUCCESS, INVALID_HANDLE, r,
78 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
80 SysAssertf(__pNetStatisticsImpl != null, "Not yet constructed. Construct() should be called before use.");
82 ret = __pNetStatisticsImpl->GetNetStatisticsInfo(operationMode, netStatType);
84 SysTryReturn(NID_NET, r == E_SUCCESS, ret, r, "[%s] Propagating.", GetErrorMessage(r));
90 NetStatistics::Reset(NetBearerType operationMode, NetStatisticsInfoType netStatType)
94 SysAssertf(__pNetStatisticsImpl != null, "Not yet constructed. Construct() should be called before use.");
96 r = __pNetStatisticsImpl->Reset(operationMode, netStatType);
97 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
103 NetStatistics::ResetAll(NetBearerType operationMode)
105 result r = E_SUCCESS;
107 SysAssertf(__pNetStatisticsImpl != null, "Not yet constructed. Construct() should be called before use.");
109 r = __pNetStatisticsImpl->ResetAll(operationMode);
110 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");