2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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.
19 * @file FNetNetAccountManagerPartner.cpp
20 * @brief This is the implementation for the %NetAccountManager class. (only partner visibility)
23 #include <FNetNetAccountManager.h>
24 #include <FBaseSysLog.h>
25 #include <FSec_AccessController.h>
26 #include <FSys_SystemInfoImpl.h>
27 #include "FNet_NetTypes.h"
28 #include "FNet_NetAccountInfoImpl.h"
29 #include "FNet_NetAccountManagerImpl.h"
30 #include "FNet_NetConnectionManagerImpl.h"
31 #include "FNet_NetIpcProxy.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Security;
35 using namespace Tizen::System;
37 namespace Tizen { namespace Net
41 NetAccountManager::UpdateSystemNetAccount(const NetAccountInfo& netAccountInfo)
44 NetBearerType bearerType = netAccountInfo.GetBearerType();
46 SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
49 if (bearerType == NET_BEARER_PS)
51 static const wchar_t _TELEPHONY[] = L"http://tizen.org/feature/network.telephony";
53 bool isTelephonySupported = false;
55 r = _SystemInfoImpl::GetSysInfo(_TELEPHONY, isTelephonySupported);
56 SysTryReturnResult(NID_NET, r == E_SUCCESS && isTelephonySupported, E_UNSUPPORTED_OPERATION, "Telephony is not supported.");
58 else if (bearerType == NET_BEARER_MMS)
60 static const wchar_t _MMS[] = L"http://tizen.org/feature/network.telephony.mms";
62 bool isMmsSupported = false;
64 r = _SystemInfoImpl::GetSysInfo(_MMS, isMmsSupported);
65 SysTryReturnResult(NID_NET, r == E_SUCCESS && isMmsSupported, E_UNSUPPORTED_OPERATION, "MMS is not supported.");
69 SysTryReturnResult(NID_NET, netAccountInfo.GetAccountId() > 0, E_INVALID_ARG,
70 "Invalid argument is used. accountId=%d", netAccountInfo.GetAccountId());
71 SysTryReturnResult(NID_NET, !netAccountInfo.GetAccountName().IsEmpty(), E_INVALID_ARG,
72 "Invalid argument is used. accountName is an empty string.");
73 SysTryReturnResult(NID_NET, ((bearerType == NET_BEARER_PS) || (bearerType == NET_BEARER_MMS)), E_INVALID_ARG,
74 "Invalid argument is used. accountId=%d", netAccountInfo.GetAccountId());
76 _NetIpcProxy* pProxy = _NetIpcProxy::GetInstance();
77 SysTryReturnResult(NID_NET, pProxy != null, E_SYSTEM,
78 "A system error has been occurred. Failed to get an IPC proxy.");
80 r = pProxy->UpdateSystemNetAccount(netAccountInfo);
81 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
87 NetAccountManager::GetAppNetAccountId(const String& netProfileName) const
90 NetAccountId netAccountId = INVALID_HANDLE;
92 SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
95 if (netProfileName.Equals(L"Internet", false))
97 static const wchar_t _TELEPHONY[] = L"http://tizen.org/feature/network.telephony";
99 bool isTelephonySupported = false;
101 r = _SystemInfoImpl::GetSysInfo(_TELEPHONY, isTelephonySupported);
102 SysTryReturn(NID_NET, r == E_SUCCESS && isTelephonySupported, INVALID_HANDLE, E_UNSUPPORTED_OPERATION,
103 "[%s] Telephony is not supported.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
105 else if (netProfileName.Equals(L"Mms", false))
107 static const wchar_t _MMS[] = L"http://tizen.org/feature/network.telephony.mms";
109 bool isMmsSupported = false;
111 r = _SystemInfoImpl::GetSysInfo(_MMS, isMmsSupported);
112 SysTryReturn(NID_NET, r == E_SUCCESS && isMmsSupported, INVALID_HANDLE, E_UNSUPPORTED_OPERATION,
113 "[%s] MMS is not supported.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
115 #endif // !_OSP_EMUL_
117 _NetIpcProxy* pProxy = _NetIpcProxy::GetInstance();
118 SysTryReturn(NID_NET, pProxy != null, INVALID_HANDLE, E_SYSTEM,
119 "[%s] A system error has been occurred. Failed to get an IPC proxy.", GetErrorMessage(E_SYSTEM));
121 r = pProxy->GetAppNetAccountId(netProfileName, netAccountId);
122 SysTryReturn(NID_NET, r == E_SUCCESS, INVALID_HANDLE, r, "[%s] Propagating.", GetErrorMessage(r));
130 NetAccountManager::SetNetAccountId(NetAccountId netAccountId)
132 result r = E_SUCCESS;
133 NetAccountId netAccountId2 = INVALID_HANDLE;
135 SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
137 SysTryReturnResult(NID_NET, netAccountId > 0, E_INVALID_ARG,
138 "Invalid argument is used. accountId=%d", netAccountId);
140 _NetConnectionManagerImpl* pConnectionManager = _NetConnectionManagerImpl::GetInstance();
141 SysTryReturnResult(NID_NET, pConnectionManager != null, E_SYSTEM,
142 "A system error has been occurred. Failed to get NetConnectionManager instance.");
144 _NetIpcProxy* pProxy = _NetIpcProxy::GetInstance();
145 SysTryReturnResult(NID_NET, pProxy != null, E_SYSTEM,
146 "A system error has been occurred. Failed to get an IPC proxy.");
148 r = pProxy->SetNetAccountId(netAccountId, netAccountId2);
149 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
151 r = pConnectionManager->SetManagedNetAccountId(netAccountId2);
152 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");