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 <API/Call/CallDefine.h>
23 #include "CallManager.h"
25 using namespace WrtDeviceApis::Commons;
26 using namespace TizenApis::Api::Call;
27 using namespace TizenApis::Api::Account;
34 CallManager::CallManager()
36 if (tel_init() == TAPI_API_SUCCESS)
37 LogDebug("TAPI init success");
40 CallManager::~CallManager()
45 bool CallManager::isCallInProgress()
51 ret = call_get_voice_call_state(&state);
53 if (ret == CALL_ERROR_NONE) {
55 case CALL_STATE_IDLE :
58 case CALL_STATE_CONNECTING:
59 case CALL_STATE_ACTIVE:
64 LogDebug("Call state changed cb error cause(" << ret << ")");
71 void CallManager::getCallService(const EventGetCallServicePtr& event)
73 EventRequestReceiver<EventGetCallService>::PostRequest(event);
76 void CallManager::OnRequestReceived(const EventGetCallServicePtr& event)
79 event->switchToManualAnswer();
81 CallServiceFilterPtr filter(event->getFilter());
82 if (filter->getServiceName().size() > 0) {
83 ThrowMsg(UnsupportedException, "Not supported filter : serviceName");
86 if (filter->getProviderId().size() > 0) {
87 ThrowMsg(UnsupportedException, "Not supported filter : providerId");
90 std::string typeId(filter->getCallType());
91 StringArrayPtr tags(filter->getTags());
93 if (typeId.compare(STR_TIZEN_TEL) != 0
94 && typeId.compare(STR_TIZEN_XMPP) != 0
95 && typeId.compare(STR_TIZEN_SIP) != 0
96 && typeId.compare("") != 0) {
97 ThrowMsg(InvalidArgumentException, "Invalid value : ServiceTypeId");
101 for (; cnt < tags->size(); cnt++) {
102 if (((*tags)[cnt]).compare(STR_CALL) != 0
103 &&((*tags)[cnt]).compare(STR_CALL_VOICE) != 0
104 && ((*tags)[cnt]).compare(STR_CALL_VIDEO) != 0
105 && ((*tags)[cnt]).compare(STR_CALL_EMERGENCY) != 0) {
106 ThrowMsg(InvalidArgumentException, "Invalid value : tags");
110 AccountServicesArrayPtr accountServicesList(new AccountServicesArray());
111 AccountServicesPtr callServices(new AccountServices());
113 if (typeId.compare(STR_TIZEN_XMPP) == 0
114 || typeId.compare(STR_TIZEN_SIP) == 0) {
115 event->setResult(accountServicesList);
116 EventRequestReceiver<EventGetCallService>::ManualAnswer(event);
119 callServices->setServiceTypeId(STR_TIZEN_TEL);
120 StringArrayPtr supportTags(new StringArray());
121 supportTags->push_back(STR_CALL_VOICE);
122 supportTags->push_back(STR_CALL_VIDEO);
123 supportTags->push_back(STR_CALL_EMERGENCY);
124 callServices->setTags(*supportTags);
125 callServices->setApplicationId(STR_TIZEN_DIALER);
127 accountServicesList->push_back(callServices);
128 event->setResult(accountServicesList);
130 EventRequestReceiver<EventGetCallService>::ManualAnswer(event);
131 } catch (const InvalidArgumentException& ex) {
132 LogError("Exception: " << ex.GetMessage());
133 event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
134 EventRequestReceiver<EventGetCallService>::ManualAnswer(event);
135 } catch (const PlatformException& ex) {
136 LogError("Exception: " << ex.GetMessage());
137 event->setExceptionCode(ExceptionCodes::PlatformException);
138 EventRequestReceiver<EventGetCallService>::ManualAnswer(event);