2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://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 <net_connection.h>
24 #include <FNetNetAccountManager.h>
25 #include <FBaseSysLog.h>
26 #include <FSec_AccessController.h>
27 #include "FNet_NetTypes.h"
28 #include "FNet_NetAccountDatabase.h"
29 #include "FNet_NetAccountInfoImpl.h"
30 #include "FNet_NetAccountManagerImpl.h"
31 #include "FNet_NetConnectionManagerImpl.h"
32 #include "FNet_NetIpcProxy.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Security;
37 namespace Tizen { namespace Net
41 NetAccountManager::UpdateSystemNetAccount(const NetAccountInfo& netAccountInfo)
45 NetBearerType bearerType = netAccountInfo.GetBearerType();
47 SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
49 SysTryReturnResult(NID_NET, netAccountInfo.GetAccountId() > 0, E_INVALID_ARG,
50 "Invalid argument is used. accountId=%d", netAccountInfo.GetAccountId());
51 SysTryReturnResult(NID_NET, !netAccountInfo.GetAccountName().IsEmpty(), E_INVALID_ARG,
52 "Invalid argument is used. accountName is an empty string.");
54 r = _NetAccountDatabase::GetProfileName(netAccountInfo.GetAccountId(), profileName);
55 SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
56 SysTryReturnResult(NID_NET, r == E_SUCCESS, E_INVALID_ARG,
57 "Invalid argument is used. accountId=%d", netAccountInfo.GetAccountId());
59 _NetIpcProxy* pProxy = _NetIpcProxy::GetInstance();
60 SysTryReturnResult(NID_NET, pProxy != null, E_SYSTEM,
61 "A system error has been occurred. Failed to get an IPC proxy.");
63 r = pProxy->UpdateSystemNetAccount(profileName, netAccountInfo, bearerType);
64 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
66 r = _NetAccountDatabase::UpdateAccountName(netAccountInfo.GetAccountId(), netAccountInfo.GetAccountName());
67 SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
68 SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
69 "A system error has been occurred. Failed to update account name.");
75 NetAccountManager::GetAppNetAccountId(const String& netProfileName) const
78 NetAccountId netAccountId = INVALID_HANDLE;
80 SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
82 _NetIpcProxy* pProxy = _NetIpcProxy::GetInstance();
83 SysTryReturn(NID_NET, pProxy != null, INVALID_HANDLE, E_SYSTEM,
84 "[%s] A system error has been occurred. Failed to get an IPC proxy.", GetErrorMessage(E_SYSTEM));
86 r = pProxy->GetAppNetAccountId(netProfileName, netAccountId);
87 SysTryReturn(NID_NET, r == E_SUCCESS, INVALID_HANDLE, r, "[%s] Propagating.", GetErrorMessage(r));
93 NetAccountManager::SetNetAccountId(NetAccountId netAccountId)
96 NetAccountId netAccountId2 = INVALID_HANDLE;
98 SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
100 SysTryReturnResult(NID_NET, netAccountId > 0, E_INVALID_ARG,
101 "Invalid argument is used. accountId=%d", netAccountId);
103 _NetConnectionManagerImpl* pConnectionManager = _NetConnectionManagerImpl::GetInstance();
104 SysTryReturnResult(NID_NET, pConnectionManager != null, E_SYSTEM,
105 "A system error has been occurred. Failed to get NetConnectionManager instance.");
107 _NetIpcProxy* pProxy = _NetIpcProxy::GetInstance();
108 SysTryReturnResult(NID_NET, pProxy != null, E_SYSTEM,
109 "A system error has been occurred. Failed to get an IPC proxy.");
111 r = pProxy->SetNetAccountId(netAccountId, netAccountId2);
112 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
114 r = pConnectionManager->SetManagedNetAccountId(netAccountId2);
115 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");