2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <Commons/Exception.h>
20 #include <dpl/log/log.h>
21 #include <API/Account/AccountServices.h>
22 #include "CallManager.h"
24 using namespace WrtDeviceApis::Commons;
25 using namespace TizenApis::Api::Call;
26 using namespace TizenApis::Api::Account;
33 CallManager::CallManager()
35 if (tel_init() == TAPI_API_SUCCESS)
36 LogDebug("TAPI init success");
39 CallManager::~CallManager()
44 bool CallManager::isCallInProgress()
50 ret = call_get_voice_call_state(&state);
52 if (ret == CALL_ERROR_NONE) {
54 case CALL_STATE_IDLE :
57 case CALL_STATE_CONNECTING:
58 case CALL_STATE_ACTIVE:
63 LogDebug("Call state changed cb error cause(" << ret << ")");
70 void CallManager::getCallService(const EventGetCallServicePtr& event)
72 EventRequestReceiver<EventGetCallService>::PostRequest(event);
75 void CallManager::OnRequestReceived(const EventGetCallServicePtr& event)
78 event->switchToManualAnswer();
80 CallServiceFilterPtr filter(event->getFilter());
81 if (filter->getServiceName().size() > 0) {
82 ThrowMsg(UnsupportedException, "Not supported filter : serviceName");
85 if (filter->getProviderId().size() > 0) {
86 ThrowMsg(UnsupportedException, "Not supported filter : providerId");
89 std::string typeId(filter->getServiceTypeId());
90 StringArrayPtr tags(filter->getTags());
92 if (typeId.compare("tizen.tel") != 0) {
93 ThrowMsg(UnsupportedException, "Not supported value : serviceTypeId");
96 for (size_t cnt = 0; cnt < tags->size(); cnt++) {
97 if (((*tags)[cnt]).compare("call") == 0
98 ||((*tags)[cnt]).compare("call.voice") == 0
99 || ((*tags)[cnt]).compare("call.video") == 0
100 || ((*tags)[cnt]).compare("call.emergency") == 0) {
103 ThrowMsg(UnsupportedException, "Not supported value : tags");
107 AccountServicesArrayPtr accountServicesList(new AccountServicesArray());
108 AccountServicesPtr callServices(new AccountServices());
110 callServices->setServiceTypeId("tizen.tel");
111 StringArrayPtr supportTags(new StringArray());
112 supportTags->push_back("call.voice");
113 supportTags->push_back("call.video");
114 supportTags->push_back("call.emergency");
115 callServices->setTags(*supportTags);
117 accountServicesList->push_back(callServices);
118 event->setResult(accountServicesList);
120 EventRequestReceiver<EventGetCallService>::ManualAnswer(event);
121 } catch (const UnsupportedException& ex) {
122 LogError("Exception: " << ex.GetMessage());
123 event->setExceptionCode(ExceptionCodes::UnsupportedException);
124 EventRequestReceiver<EventGetCallService>::ManualAnswer(event);
125 } catch (const PlatformException& ex) {
126 LogError("Exception: " << ex.GetMessage());
127 event->setExceptionCode(ExceptionCodes::PlatformException);
128 EventRequestReceiver<EventGetCallService>::ManualAnswer(event);