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 CallManager.cpp
19 * @brief This is the implementation file for CallManager class.
22 #include <FTelCallManager.h>
23 #include <FBaseSysLog.h>
24 #include <FSec_AccessController.h>
25 #include <FSys_SystemInfoImpl.h>
26 #include "FTel_CallManagerImpl.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Security;
30 using namespace Tizen::System;
33 namespace Tizen { namespace Telephony
35 CallManager::CallManager(void)
36 : __pCallManagerImpl(null)
40 CallManager::~CallManager(void)
42 delete __pCallManagerImpl;
46 CallManager::Construct(void)
48 static const wchar_t _TELEPHONY[] = L"http://tizen.org/feature/network.telephony";
50 SysAssertf(__pCallManagerImpl == null,
51 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
54 bool isTelephonySupported = false;
56 r = _SystemInfoImpl::GetSysInfo(_TELEPHONY, isTelephonySupported);
57 SysTryReturnResult(NID_TEL, r == E_SUCCESS && isTelephonySupported, E_UNSUPPORTED_OPERATION, "Telephony is not supported.");
59 __pCallManagerImpl = new (std::nothrow) _CallManagerImpl();
60 SysTryReturnResult(NID_TEL, __pCallManagerImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
62 r = __pCallManagerImpl->Construct();
65 SysLogException(NID_TEL, r, "[%s] Propagating.", GetErrorMessage(r));
66 delete __pCallManagerImpl;
67 __pCallManagerImpl = null;
74 CallManager::Construct(ITelephonyCallEventListener& listener)
76 static const wchar_t _TELEPHONY[] = L"http://tizen.org/feature/network.telephony";
78 SysAssertf(__pCallManagerImpl == null,
79 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
82 bool isTelephonySupported = false;
84 r = _SystemInfoImpl::GetSysInfo(_TELEPHONY, isTelephonySupported);
85 SysTryReturnResult(NID_TEL, r == E_SUCCESS && isTelephonySupported, E_UNSUPPORTED_OPERATION, "Telephony is not supported.");
87 __pCallManagerImpl = new (std::nothrow) _CallManagerImpl();
88 SysTryReturnResult(NID_TEL, __pCallManagerImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
90 r = __pCallManagerImpl->Construct(&listener);
94 SysLogException(NID_TEL, r, "[%s] Propagating.", GetErrorMessage(r));
95 delete __pCallManagerImpl;
96 __pCallManagerImpl = null;
103 CallManager::SetCallForwardListener(ITelephonyCallForwardListener* pListener)
105 SysAssertf(__pCallManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
107 result r = E_SUCCESS;
109 r = __pCallManagerImpl->SetCallForwardListener(pListener);
111 if (r == E_PRIVILEGE_DENIED)
113 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
115 else if( r != E_SUCCESS)
117 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
124 CallManager::RequestCallForward(const String& phoneNumber)
126 SysAssertf(__pCallManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
128 result r = E_SUCCESS;
130 r = __pCallManagerImpl->RequestCallForward(phoneNumber);
132 if (r == E_PRIVILEGE_DENIED)
134 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
136 else if( r != E_SUCCESS)
138 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
145 CallManager::StopCallForward(void)
147 SysAssertf(__pCallManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
149 result r = E_SUCCESS;
151 r = __pCallManagerImpl->StopCallForward();
153 if (r == E_PRIVILEGE_DENIED)
155 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
157 else if( r != E_SUCCESS)
159 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
166 CallManager::GetCallForwardNumber(void) const
168 SysAssertf(__pCallManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
170 result r = E_SUCCESS;
172 r = __pCallManagerImpl->GetCallForwardNumber();
174 if (r == E_PRIVILEGE_DENIED)
176 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
178 else if( r != E_SUCCESS)
180 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
187 CallManager::GetCurrentCallType(void) const
189 SysAssertf(__pCallManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
191 CallType callType = TYPE_UNDEFINED_CALL;
193 callType = __pCallManagerImpl->GetCurrentCallType();
199 CallManager::GetCurrentCallStatus(void) const
201 SysAssertf(__pCallManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
203 CallStatus callStatus = CALL_STATUS_UNDEFINED;
205 callStatus = __pCallManagerImpl->GetCurrentCallStatus();
210 }} // Tizen::Telephony