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.
19 * @file FTel_TelephonyIpcProxy.cpp
20 * @brief This is the implementation file for the %_TelephonyIpcProxy class.
22 * This file contains the implementation of the %_TelephonyIpcProxy class.
26 #include <unique_ptr.h>
27 #include <FBaseSysLog.h>
28 #include <FIo_IpcClient.h>
29 #include <FTel_ConnectivityIpcMessages.h>
30 #include "FTel_TelephonyIpcProxy.h"
31 #include "FTel_CallManagerImpl.h"
32 #include "FTel_NetworkManagerImpl.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Io;
37 namespace Tizen { namespace Telephony
40 _TelephonyIpcProxy* _TelephonyIpcProxy::__pInstance = null;
42 _TelephonyIpcProxy::_TelephonyIpcProxy(void)
44 , __pNetworkManagerImplForGet(null)
45 , __pNetworkManagerImplForSelect(null)
46 , __pNetworkManagerImplForSearch(null)
47 , __pCallManagerImplForGet(null)
48 , __pCallManagerImplForStart(null)
49 , __pCallManagerImplForStop(null)
53 _TelephonyIpcProxy::~_TelephonyIpcProxy(void)
59 _TelephonyIpcProxy::Construct(void)
63 __pIpcClient = new (std::nothrow) _IpcClient();
64 SysTryReturnResult(NID_TEL, __pIpcClient != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
66 r = __pIpcClient->Construct(TELEPHONY_CONNECTIVITY_IPC_SERVER_NAME, this);
67 SysTryReturnResult(NID_TEL, r != E_OUT_OF_MEMORY, r, "Propagating.");
71 SysLogException(NID_TEL, r, "[%s] Propagating", GetErrorMessage(r));
80 _TelephonyIpcProxy::GetInstance(void)
82 static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
84 if (__pInstance == null)
87 pthread_once(&onceBlock, InitSingleton);
88 result r = GetLastResult();
91 onceBlock = PTHREAD_ONCE_INIT;
99 _TelephonyIpcProxy::InitSingleton(void)
101 result r = E_SUCCESS;
102 static _TelephonyIpcProxy instance;
104 r = instance.Construct();
105 SysTryReturnVoidResult(NID_TEL, r == E_SUCCESS, r, "[%s] Propagating", GetErrorMessage(r));
107 __pInstance = &instance;
111 _TelephonyIpcProxy::GetImsi(Tizen::Base::String& imsi) const
113 result r = E_SUCCESS;
114 unsigned long ret = 0;
116 std::unique_ptr<IPC::Message> pMessage( new (std::nothrow) ConnectivityTelephonyServiceMsg_getImsi(&imsi, &ret));
117 SysTryReturnResult(NID_TEL, pMessage!= null , E_OUT_OF_MEMORY, "Memory allocation failed.");
119 r = __pIpcClient->SendRequest(*pMessage);
121 SysTryReturnResult(NID_TEL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to send a request.");
122 SysTryReturnResult(NID_TEL, ret == E_SUCCESS, ret, "Propagating.");
124 SysLog(NID_TEL, "The Telephony Imsi obtained through IPC is %ls.", imsi.GetPointer());
130 _TelephonyIpcProxy::HasSystemPrivilege(void)
132 result r = E_SUCCESS;
133 unsigned long ret = 0;
135 std::unique_ptr<IPC::Message> pMessage( new (std::nothrow) ConnectivityTelephonyServiceMsg_hasSystemPrivilege(&ret));
136 SysTryReturnResult(NID_TEL, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
138 r = __pIpcClient->SendRequest(*pMessage);
139 SysTryReturnResult(NID_TEL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to send a request.");
140 SysTryReturnResult(NID_TEL, ret == E_SUCCESS, ret, "Propagating.");
146 _TelephonyIpcProxy::GetNetworkSelectionMode(_NetworkManagerImpl* pNetworkManagerImpl)
148 result r = E_SUCCESS;
149 unsigned long ret = 0;
151 std::unique_ptr<IPC::Message> pMessage( new (std::nothrow) ConnectivityTelephonyServiceMsg_getNetworkSelectionMode(&ret));
152 SysTryReturnResult(NID_TEL, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
154 r = __pIpcClient->SendRequest(*pMessage);
155 SysTryReturnResult(NID_TEL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to send a request.");
156 SysTryReturnResult(NID_TEL, ret == E_SUCCESS, ret, "Propagating.");
158 __pNetworkManagerImplForGet = pNetworkManagerImpl;
164 _TelephonyIpcProxy::SelectNetwork(_NetworkManagerImpl* pNetworkManagerImpl, const Tizen::Base::String& plmn, const int netwokrType)
166 result r = E_SUCCESS;
167 unsigned long ret = 0;
169 std::unique_ptr<IPC::Message> pMessage( new (std::nothrow) ConnectivityTelephonyServiceMsg_selectNetworkManual(plmn, netwokrType, &ret));
170 SysTryReturnResult(NID_TEL, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
172 r = __pIpcClient->SendRequest(*pMessage);
173 SysTryReturnResult(NID_TEL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to send a request.");
174 SysTryReturnResult(NID_TEL, ret == E_SUCCESS, ret, "Propagating.");
176 __pNetworkManagerImplForSelect = pNetworkManagerImpl;
182 _TelephonyIpcProxy::SelectNetwork(_NetworkManagerImpl* pNetworkManagerImpl)
184 result r = E_SUCCESS;
185 unsigned long ret = 0;
187 std::unique_ptr<IPC::Message> pMessage( new (std::nothrow) ConnectivityTelephonyServiceMsg_selectNetworkAutomatic(&ret));
188 SysTryReturnResult(NID_TEL, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
190 r = __pIpcClient->SendRequest(*pMessage);
191 SysTryReturnResult(NID_TEL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to send a request.");
192 SysTryReturnResult(NID_TEL, ret == E_SUCCESS, ret, "Propagating.");
194 __pNetworkManagerImplForSelect = pNetworkManagerImpl;
201 _TelephonyIpcProxy::SearchNetwork(_NetworkManagerImpl* pNetworkManagerImpl)
203 result r = E_SUCCESS;
204 unsigned long ret = 0;
206 std::unique_ptr<IPC::Message> pMessage( new (std::nothrow) ConnectivityTelephonyServiceMsg_searchNetwork(&ret));
207 SysTryReturnResult(NID_TEL, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
209 r = __pIpcClient->SendRequest(*pMessage);
210 SysTryReturnResult(NID_TEL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to send a request.");
211 SysTryReturnResult(NID_TEL, ret == E_SUCCESS, ret, "Propagating.");
213 __pNetworkManagerImplForSearch = pNetworkManagerImpl;
220 _TelephonyIpcProxy::HasCallForwardPrivilege(void)
222 result r = E_SUCCESS;
223 unsigned long ret = 0;
225 std::unique_ptr<IPC::Message> pMessage( new (std::nothrow) ConnectivityTelephonyServiceMsg_hasCallForwardPrivilege(&ret));
226 SysTryReturnResult(NID_TEL, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
228 r = __pIpcClient->SendRequest(*pMessage);
229 SysTryReturnResult(NID_TEL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to send a request.");
230 SysTryReturnResult(NID_TEL, ret == E_SUCCESS, ret, "Propagating.");
236 _TelephonyIpcProxy::RequestCallForward(_CallManagerImpl* pCallManagerImpl, const String& phoneNumber)
238 result r = E_SUCCESS;
239 unsigned long ret = 0;
241 std::unique_ptr<IPC::Message> pMessage( new (std::nothrow) ConnectivityTelephonyServiceMsg_requestCallForward(phoneNumber, &ret));
242 SysTryReturnResult(NID_TEL, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
244 r = __pIpcClient->SendRequest(*pMessage);
245 SysTryReturnResult(NID_TEL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to send a request.");
246 SysTryReturnResult(NID_TEL, ret == E_SUCCESS, ret, "Propagating.");
248 __pCallManagerImplForStart = pCallManagerImpl;
254 _TelephonyIpcProxy::StopCallForward(_CallManagerImpl* pCallManagerImpl)
256 result r = E_SUCCESS;
257 unsigned long ret = 0;
259 std::unique_ptr<IPC::Message> pMessage( new (std::nothrow) ConnectivityTelephonyServiceMsg_stopCallForward(&ret));
260 SysTryReturnResult(NID_TEL, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
262 r = __pIpcClient->SendRequest(*pMessage);
263 SysTryReturnResult(NID_TEL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to send a request.");
264 SysTryReturnResult(NID_TEL, ret == E_SUCCESS, ret, "Propagating.");
266 __pCallManagerImplForStop = pCallManagerImpl;
272 _TelephonyIpcProxy::GetCallForwardNumber(_CallManagerImpl* pCallManagerImpl)
274 result r = E_SUCCESS;
275 unsigned long ret = 0;
277 std::unique_ptr<IPC::Message> pMessage( new (std::nothrow) ConnectivityTelephonyServiceMsg_getCallForwardNumber(&ret));
278 SysTryReturnResult(NID_TEL, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed.");
280 r = __pIpcClient->SendRequest(*pMessage);
281 SysTryReturnResult(NID_TEL, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to send a request.");
282 SysTryReturnResult(NID_TEL, ret == E_SUCCESS, ret, "Propagating.");
284 __pCallManagerImplForGet = pCallManagerImpl;
290 _TelephonyIpcProxy::OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message)
292 SysLog(NID_TEL, "OnIpcResponseReceived");
294 IPC_BEGIN_MESSAGE_MAP(_TelephonyIpcProxy, message)
295 IPC_MESSAGE_HANDLER(ConnectivityTelephonyServiceMsg_onNetworkSelectionModeReceived, OnNetworkSelectionModeReceived, &client)
296 IPC_MESSAGE_HANDLER(ConnectivityTelephonyServiceMsg_onNetworkSelectionCompleted, OnNetworkSelectionCompleted, &client)
297 IPC_MESSAGE_HANDLER(ConnectivityTelephonyServiceMsg_onNetworkSearchCompleted, OnNetworkSearchCompleted, &client)
298 IPC_MESSAGE_HANDLER(ConnectivityTelephonyServiceMsg_onCallForwardNumberReceived, OnTelephonyCallForwardNumberReceived, &client);
299 IPC_MESSAGE_HANDLER(ConnectivityTelephonyServiceMsg_onCallForwardResponseReceived, OnTelephonyCallForwardResponseReceived, &client);
300 IPC_MESSAGE_HANDLER(ConnectivityTelephonyServiceMsg_onCallForwardStopped, OnTelephonyCallForwardStopped, &client);
301 IPC_END_MESSAGE_MAP()
305 _TelephonyIpcProxy::OnNetworkSelectionModeReceived(bool isManual, unsigned long res)
307 SysLog(NID_TEL, "The listener has been called.");
309 SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.");
311 __pNetworkManagerImplForGet->OnTelephonyNetworkSelectionModeReceived(isManual, res);
315 _TelephonyIpcProxy::OnNetworkSelectionCompleted(unsigned long res)
317 SysLog(NID_TEL, "The listener has been called.");
319 SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.");
321 __pNetworkManagerImplForSelect->OnTelephonyNetworkSelectionCompleted(res);
325 _TelephonyIpcProxy::OnNetworkSearchCompleted(Tizen::Base::String message, unsigned long res)
327 SysLog(NID_TEL, "The listener has been called.");
329 SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.");
331 __pNetworkManagerImplForSearch->OnTelephonyNetworkSearchCompleted(message, res);
335 _TelephonyIpcProxy::OnTelephonyCallForwardNumberReceived(Tizen::Base::String phoneNumber, unsigned long res)
337 SysLog(NID_TEL, "The listener has been called.");
339 SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.");
341 __pCallManagerImplForGet->OnTelephonyCallForwardNumberReceived(phoneNumber, res);
345 _TelephonyIpcProxy::OnTelephonyCallForwardResponseReceived(Tizen::Base::String phoneNumber, unsigned long res)
347 SysLog(NID_TEL, "The listener has been called.");
349 SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.");
351 __pCallManagerImplForStart->OnTelephonyCallForwardResponseReceived(phoneNumber, res);
355 _TelephonyIpcProxy::OnTelephonyCallForwardStopped(Tizen::Base::String phoneNumber, unsigned long res)
357 SysLog(NID_TEL, "The listener has been called.");
359 SysAssertf(__pIpcClient != null, "Not yet constructed. Construct() should be called before use.");
361 __pCallManagerImplForStop->OnTelephonyCallForwardStopped(phoneNumber, res);
364 }} // Tizen::Telephony