#include "ucl/appfw/SysEventProvider.h"
-
#include "model/Call.h"
namespace callui {
public:
Instance(ucl::SysEventProvider &sysEventProvider);
+ // For testing
+ ucl::WindowWRef getWindow();
+ ucl::IInstanceContext *getContext();
+ CallWRef getCall();
+
// IInstance //
virtual ucl::Result onCreate(
ucl::SysEventProvider &m_sysEventProvider;
ucl::IInstanceContext *m_context;
ucl::WindowSRef m_win;
-
CallSRef m_call;
};
}
#ifndef __CALLUI_MODEL_CALL_H__
#define __CALLUI_MODEL_CALL_H__
+#include <app_control.h>
+
#include "types.h"
namespace callui {
class Call final : public ucl::NonCopyable {
public:
- static CallSRef newInstance();
+ class Builder {
+ public:
+ Builder();
+ Builder &setListener(ICallManagerListenerWRef value);
+ CallSRef build() const;
+ private:
+ ICallManagerListenerWRef m_listener;
+ };
+
+ public:
virtual ~Call();
+ ucl::Result processAppControl(app_control_h appControl);
ISoundManagerSRef getSoundManager();
ICallManagerSRef getCallManager();
friend class ucl::RefCountObj<Call>;
Call();
- ucl::Result prepare();
+ ucl::Result prepare(ICallManagerListenerWRef listener);
private:
CallManagerSRef m_callManager;
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __CALLUI_MODEL_I_CALL_DIALER_H__
-#define __CALLUI_MODEL_I_CALL_DIALER_H__
-
-#include "types.h"
-
-namespace callui {
-
- class ICallDialer: public ucl::Polymorphic {
- public:
- virtual ucl::Result dialVoiceCall(const std::string &number, SimSlot simSlot) = 0;
- virtual void addDialStatusHandler(DialStatusHandler handler) = 0;
- virtual void removeDialStatusHandler(DialStatusHandler handler) = 0;
- };
-}
-
-#endif // __CALLUI_MODEL_I_CALL_DIALER_H__
class ICallManager : public ucl::Polymorphic {
public:
- virtual ICallDialerWRef getDialer() = 0;
virtual IIncomingCallWRef getIncomingCall() = 0;
virtual IActiveCallWRef getActiveCall() = 0;
virtual IHeldCallWRef getHeldCall() = 0;
virtual IEndCallWRef getEndCall() = 0;
- virtual void addCallStateHandler(CallStateHandler handler) = 0;
- virtual void removeCallStateHandler(CallStateHandler handler) = 0;
};
}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CALLUI_MODEL_I_CALL_MANAGER_LISTENER_H__
+#define __CALLUI_MODEL_I_CALL_MANAGER_LISTENER_H__
+
+#include "types.h"
+
+namespace callui {
+
+ class ICallManagerListener : public ucl::Polymorphic {
+ public:
+ virtual void onCallEvent(CallEventType type) = 0;
+ virtual void onError(CallManagerErr err) = 0;
+ };
+
+}
+
+#endif // __CALLUI_MODEL_I_CALL_MANAGER_LISTENER_H__
namespace callui {
enum class SimSlot {
+ UNDEFINED,
FIRST,
SECOND,
DEFAULT
};
+ enum class CallManagerErr {
+ NONE,
+ DIAL_CANCEL,
+ DIAL_FAIL,
+ DIAL_FAIL_SS,
+ DIAL_FAIL_FDN,
+ DIAL_FLIGHT_MODE
+ };
+
enum class CallAnswerType {
NORMAL,
HOLD_ACTIVE_AND_ACCEPT,
RELEASE_ALL_AND_ACCEPT
};
- enum class DialStatus {
- SUCCESS,
- CANCEL,
- FAIL,
- FAIL_SS,
- FAIL_FDN,
- FLIGHT_MODE
- };
-
enum class AudioStateType {
NONE,
SPEAKER,
UCL_DECLARE_REF_ALIASES(ICallManager);
UCL_DECLARE_REF_ALIASES(ISoundManager);
- UCL_DECLARE_REF_ALIASES(ICallDialer);
+
+ UCL_DECLARE_REF_ALIASES(ICallManagerListener);
UCL_DECLARE_REF_ALIASES(IIncomingCall);
UCL_DECLARE_REF_ALIASES(IActiveCall);
UCL_DECLARE_REF_ALIASES(IRejectMsgProvider);
UCL_DECLARE_REF_ALIASES(IRejectMsg);
- using CallStateHandler = ucl::Delegate<void(CallEventType)>;
-
- using DialStatusHandler = ucl::Delegate<void(DialStatus)>;
-
using AudioStateHandler = ucl::Delegate<void(AudioStateType)>;
using MuteStateHandler = ucl::Delegate<void(bool)>;
#include "main/Instance.h"
+#include "ucl/util/memory.h"
+
#include <system_settings.h>
#include <efl_extension.h>
#include "../common.h"
+#include "model/ICallManager.h"
+#include "model/ICallManagerListener.h"
+#include "model/IIncomingCall.h"
+#include "model/IActiveCall.h"
+#include "model/IHeldCall.h"
+#include "model/IEndCall.h"
+#include "model/ICallInfo.h"
+
namespace callui {
using namespace ucl;
+ // For testing
+ UCL_DECLARE_REF_ALIASES(Listener);
+ class Listener : public ICallManagerListener {
+ public:
+ static ListenerSRef newInstance(Instance &instance)
+ {
+ return makeShared<Listener>(instance);
+ }
+ virtual void onCallEvent(CallEventType type) override final
+ {
+ WindowWRef win = m_instance.getWindow();
+ CallWRef call = m_instance.getCall();
+ ICallManagerSRef callMng = {};
+ if (call) {
+ callMng = call->getCallManager();
+ }
+
+ if (win && !win->isVisible()) {
+ show(*win);
+ }
+
+ IIncomingCallWRef incom = callMng->getIncomingCall();
+ IActiveCallWRef active = callMng->getActiveCall();
+ IHeldCallWRef held = callMng->getHeldCall();
+ IEndCallWRef end = callMng->getEndCall();
+
+ ILOG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+ if (incom) {
+ ILOG("Incoming call available");
+ logCallInfo(incom->getInfo());
+ } else {
+ ILOG("No incoming call");
+ }
+
+ if (active) {
+ ILOG("Active call available");
+ logCallInfo(active->getInfo());
+ } else {
+ ILOG("No active call");
+ }
+
+ if (held) {
+ ILOG("Held call available");
+ logCallInfo(held->getInfo());
+ } else {
+ ILOG("No held call");
+ }
+
+ if (end) {
+ ILOG("End call available");
+ logCallInfo(end->getInfo());
+ } else {
+ ILOG("No end call");
+ }
+ ILOG("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+
+ if (type == CallEventType::END) {
+ if (!callMng->getIncomingCall()
+ && !callMng->getActiveCall()
+ && !callMng->getHeldCall()) {
+ IInstanceContext *ctx = m_instance.getContext();
+ if (ctx) {
+ ctx->exitApp();
+ }
+ }
+ }
+ }
+
+ virtual void onError(CallManagerErr err) override final
+ {
+ ILOG();
+ }
+
+ private:
+ void logCallInfo(ICallInfoSCRef info)
+ {
+ ILOG("* call id [%d]", info->getCallId());
+ ILOG("* phone number [%s]", info->getPhoneNumber().c_str());
+ ILOG("* conference member count [%d]", info->getConferenceMemberCount());
+ }
+
+ private:
+ friend class ucl::RefCountObj<Listener>;
+ Listener(Instance &instance):
+ m_instance(instance)
+ {
+ ILOG();
+ }
+ private:
+ Instance &m_instance;
+ };
+
Instance::Instance(SysEventProvider &sysEventProvider) :
m_sysEventProvider(sysEventProvider),
m_context(nullptr)
eext_object_event_callback_add(*m_win, EEXT_CALLBACK_BACK,
CALLBACK_A(Instance::onBack), this);
- m_call = Call::newInstance();
+ // For testing
+ static ListenerSRef listener = Listener::newInstance(*this);
+ m_call = Call::Builder().
+ setListener(listener).
+ build();
+
+ if (!m_call) {
+ LOG_RETURN(RES_FAIL, "m_call is NULL");
+ }
return RES_OK;
}
ILOG("operation: %s", op);
free(op);
- if (!m_win->isVisible()) {
- show(*m_win);
+ // For testing
+ Result res = m_call->processAppControl(appControl);
+ if (res != RES_OK) {
+ ELOG("processAppControl() failed!");
+ ICallManagerSRef callManager = m_call->getCallManager();
+ if (!callManager->getIncomingCall()
+ && !callManager->getActiveCall()
+ && !callManager->getHeldCall()
+ && !callManager->getEndCall()) {
+ ILOG("No calls. Exit application");
+ m_context->exitApp();
+ }
}
}
break;
}
}
+
+ WindowWRef Instance::getWindow()
+ {
+ return m_win;
+ }
+
+ IInstanceContext *Instance::getContext()
+ {
+ return m_context;
+ }
+
+ CallWRef Instance::getCall()
+ {
+ return m_call;
+ }
}
using namespace ucl;
ActiveCall::ActiveCall(CallManager &cm, cm_call_data_h callData):
- BaseCall(callData),
m_cm(cm),
m_isDialing(false)
{
}
auto result = makeShared<ActiveCall>(cm, callData);
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
return result;
}
- Result ActiveCall::prepare()
+ Result ActiveCall::prepare(cm_call_data_h callData)
{
- m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), m_callData);
+ m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), callData);
if (!m_callInfo) {
LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
}
cm_call_state_e callState = CM_CALL_STATE_IDLE;
FAIL_RETURN(convertCMResult(
- cm_call_data_get_call_state(m_callData, &callState)),
+ cm_call_data_get_call_state(callData, &callState)),
"cm_call_data_get_call_state() failed!");
m_isDialing = (callState == CM_CALL_STATE_DIALING);
#include <call-manager-ext.h>
-#include "BaseCall.h"
#include "model/IActiveCall.h"
#include "implTypes.h"
namespace callui {
- class ActiveCall final :
- public BaseCall,
- public IActiveCall {
+ class ActiveCall final : public IActiveCall {
public:
static ActiveCallSRef newInstance(CallManager &cm, cm_call_data_h callData);
virtual ~ActiveCall();
friend class ucl::RefCountObj<ActiveCall>;
ActiveCall(CallManager &cm, cm_call_data_h callData);
- ucl::Result prepare();
+ ucl::Result prepare(cm_call_data_h callData);
private:
CallManager &m_cm;
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "BaseCall.h"
-
-namespace callui {
-
- BaseCall::BaseCall(cm_call_data_h callData):
- m_callData(callData)
- {
- }
-
- BaseCall::~BaseCall()
- {
- }
-
- cm_call_data_h BaseCall::getCallData()
- {
- return m_callData;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __CALLUI_MODEL_BASE_CALL_H__
-#define __CALLUI_MODEL_BASE_CALL_H__
-
-#include <call-manager-ext.h>
-
-namespace callui {
-
- class BaseCall {
- public:
- BaseCall(cm_call_data_h callData);
- virtual ~BaseCall();
-
- cm_call_data_h getCallData();
- protected:
- cm_call_data_h m_callData;
- };
-
-}
-
-#endif // __CALLUI_MODEL_BASE_CALL_H__
#include "model/Call.h"
+#include <app_control.h>
+
#include "CallClient.h"
#include "CallManager.h"
#include "SoundManager.h"
using namespace ucl;
- Call::Call()
+ Call::Builder::Builder():
+ m_listener(nullptr)
{
}
- Call::~Call()
+ Call::Builder &Call::Builder::setListener(ICallManagerListenerWRef value)
{
+ m_listener = value;
+ return *this;
}
- CallSRef Call::newInstance()
+ CallSRef Call::Builder::build() const
{
auto result = makeShared<Call>();
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ FAIL_RETURN_VALUE(result->prepare(m_listener), {}, "result->prepare() failed!");
return result;
}
- Result Call::prepare()
+ Call::Call()
+ {
+ }
+
+ Call::~Call()
+ {
+ }
+
+ Result Call::processAppControl(app_control_h appControl)
+ {
+ if (!appControl) {
+ FAIL_RETURN(RES_INVALID_ARGUMENTS, "appControl is NULL");
+ }
+
+ Result ret = RES_FAIL;
+
+ char *operation = nullptr;
+ int res = app_control_get_operation(appControl, &operation);
+ if (res != APP_CONTROL_ERROR_NONE) {
+ LOG_RETURN(RES_FAIL, "app_control_get_operation() failed!");
+ }
+ if (!operation) {
+ LOG_RETURN(RES_FAIL, "operation is NULL!");
+ }
+
+ char *uri = nullptr;
+ res = app_control_get_uri(appControl, &uri);
+ if (res != APP_CONTROL_ERROR_NONE) {
+ free(operation);
+ LOG_RETURN(RES_FAIL, "app_control_get_uri() failed!");
+ }
+ if (!uri) {
+ free(operation);
+ LOG_RETURN(RES_FAIL, "uri is NULL!");
+ }
+
+ if (strcmp(operation, APP_CONTROL_OPERATION_CALL) || strncmp(uri, "tel:", 4)) {
+ free(operation);
+ free(uri);
+ LOG_RETURN(RES_FAIL, "Not processed operation!");
+ }
+
+ char *tmp = nullptr;
+ if (!strncmp(uri, "tel:MT", 6)) {
+ res = app_control_get_extra_data(appControl, "sim_slot", &tmp);
+ if (res != APP_CONTROL_ERROR_NONE) {
+ ELOG("app_control_get_extra_data() failed!");
+ }
+ if (!tmp) {
+ free(operation);
+ free(uri);
+ LOG_RETURN(RES_FAIL, "Sim slot is NULL!");
+ }
+ DLOG("Sim slot [%s]", tmp);
+ free(tmp);
+
+ ret = m_callManager->processIncomingCall(
+ convertCMSimSlot(static_cast<cm_multi_sim_slot_type_e>(atoi(tmp))));
+
+ } else {
+ tmp = static_cast<char *>(uri + 4);
+ DLOG("number [%s]", tmp);
+
+ if (!tmp) {
+ free(operation);
+ free(uri);
+ LOG_RETURN(RES_FAIL, "number is NULL");
+ }
+
+ ret = m_callManager->processOutgoingCall(tmp);
+ }
+
+ free(operation);
+ free(uri);
+
+ return ret;
+ }
+
+ Result Call::prepare(ICallManagerListenerWRef listener)
{
CallClientSRef callClient = CallClient::newInstance();
if (!callClient) {
LOG_RETURN(RES_FAIL, "Client::newInstance() failed!");
}
- m_callManager = CallManager::newInstance(callClient);
+ m_callManager = CallManager::newInstance(callClient, listener);
if (!m_callManager) {
LOG_RETURN(RES_FAIL, "CallManager::newInstance() failed!");
}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "CallDialer.h"
-
-#include "CallManager.h"
-#include "CallClient.h"
-
-#include "common.h"
-
-namespace callui {
-
- using namespace ucl;
-
- CallDialer::CallDialer(CallManager &cm):
- m_cm(cm)
- {
- }
-
- CallDialer::~CallDialer()
- {
- cm_unset_dial_status_cb(*(m_cm.getCallClient()));
- }
-
- CallDialerSRef CallDialer::newInstance(CallManager &cm)
- {
- auto result = makeShared<CallDialer>(cm);
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- void CallDialer::DialStatusChangedCb(cm_dial_status_e status)
- {
- m_event.invoke(convertCMDialStatus(status));
- }
-
- Result CallDialer::prepare()
- {
- return convertCMResult(
- cm_set_dial_status_cb(*(m_cm.getCallClient()),
- CALLBACK_B(CallDialer::DialStatusChangedCb), this));
- }
-
- Result CallDialer::dialVoiceCall(const std::string &number, SimSlot simSlot)
- {
- char buff[TEL_NUMBER_MAX_SIZE] = { 0 };
- snprintf(buff, sizeof(buff), "%s", number.c_str());
-
- return convertCMResult(
- cm_dial_call(*(m_cm.getCallClient()),
- buff, CM_CALL_TYPE_VOICE, convertCUISimSlot(simSlot)));
- }
-
- void CallDialer::addDialStatusHandler(DialStatusHandler handler)
- {
- m_event += handler;
- }
-
- void CallDialer::removeDialStatusHandler(DialStatusHandler handler)
- {
- m_event -= handler;
- }
-}
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __CALLUI_MODEL_CALL_DIALER_H__
-#define __CALLUI_MODEL_CALL_DIALER_H__
-
-#include <call-manager-ext.h>
-
-#include "model/ICallDialer.h"
-
-#include "implTypes.h"
-
-namespace callui {
-
- class CallDialer final : public ICallDialer {
- public:
- static CallDialerSRef newInstance(CallManager &cm);
- virtual ~CallDialer();
-
- // ICallDialer
-
- virtual ucl::Result dialVoiceCall(const std::string &number, SimSlot simSlot) override final;
- virtual void addDialStatusHandler(DialStatusHandler handler) override final;
- virtual void removeDialStatusHandler(DialStatusHandler handler) override final;
-
- private:
- friend class ucl::RefCountObj<CallDialer>;
- CallDialer(CallManager &cm);
-
- ucl::Result prepare();
- void DialStatusChangedCb(cm_dial_status_e dial_status);
-
- private:
- CallManager &m_cm;
- DialStatusEvent m_event;
- };
-
-}
-
-#endif // __CALLUI_MODEL_CALL_DIALER_H__
#include "CallManager.h"
+#include "model/ICallManagerListener.h"
+
#include "CallClient.h"
#include "RejectMsgProvider.h"
-#include "CallDialer.h"
#include "IncomingCall.h"
#include "ActiveCall.h"
#include "HeldCall.h"
using namespace ucl;
- CallManager::CallManager(const CallClientSRef &callClient):
- m_callClient(callClient)
+ CallManager::CallManager(const CallClientSRef &callClient,
+ ICallManagerListenerWRef listener):
+ m_callClient(callClient),
+ m_listener(listener),
+ m_slot(SimSlot::UNDEFINED),
+ m_waitDialing(false)
{
}
{
}
- CallManagerSRef CallManager::newInstance(const CallClientSRef &callClient)
+ CallManagerSRef CallManager::newInstance(const CallClientSRef &callClient,
+ ICallManagerListenerWRef listener)
{
- auto result = makeShared<CallManager>(callClient);
+ auto result = makeShared<CallManager>(callClient, listener);
FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
return result;
}
Result CallManager::prepare()
{
- m_dialer = CallDialer::newInstance(*this);
- if (!m_dialer) {
- LOG_RETURN(RES_FAIL, "CallDialer::getInstance() failed!");
- }
-
FAIL_RETURN(initCalls(), "initCalls() failed!");
FAIL_RETURN(convertCMResult(
- cm_set_call_event_cb(*m_callClient, CALLBACK_B(CallManager::callEventCb), this)),
+ cm_set_dial_status_cb(*m_callClient,
+ CALLBACK_B(CallManager::dialStatusCb), this)),
+ "cm_set_call_event_cb() failed!");
+
+ FAIL_RETURN(convertCMResult(
+ cm_set_call_event_cb(*m_callClient,
+ CALLBACK_B(CallManager::callEventCb), this)),
"cm_set_call_event_cb() failed!");
return RES_OK;
cm_get_all_calldata(*m_callClient, &incom, &active, &held)),
"cm_get_all_calldata() failed!");
- FAIL_RETURN(updateIncomingCall(incom), "updateIncomingCall() failed!");
- FAIL_RETURN(updateActiveCall(active), "updateActiveCall() failed!");
- FAIL_RETURN(updateHeldCall(held), "updateHeldCall() failed!");
+ FAIL_RETURN(updateCall(m_incomingCall, incom), "updateCall() failed!");
+ FAIL_RETURN(updateCall(m_activeCall, active), "updateCall() failed!");
+ FAIL_RETURN(updateCall(m_heldCall, held), "updateCall() failed!");
return RES_OK;
}
- Result CallManager::updateIncomingCall(cm_call_data_h incom, SimSlot slot)
+ template <class TYPE, class TYPE2>
+ Result CallManager::updateCall(SharedRef<TYPE> &call, TYPE2 &&data)
{
- if (incom) {
- m_incomingCall = IncomingCall::newInstance(*this, incom, slot);
- if (!m_incomingCall) {
- LOG_RETURN(RES_FAIL, "IncomingCall::newInstance() failed!");
- }
- } else {
- m_incomingCall.reset();
- }
+ call.reset();
- return RES_OK;
- }
-
- Result CallManager::updateActiveCall(cm_call_data_h active)
- {
- if (active) {
- m_activeCall = ActiveCall::newInstance(*this, active);
- if (!m_activeCall) {
- LOG_RETURN(RES_FAIL, "ActiveCall::newInstance() failed!");
+ if (data) {
+ call = TYPE::newInstance(*this, std::forward<TYPE2>(data));
+ if (!call) {
+ LOG_RETURN(RES_FAIL, "newInstance() failed!");
}
- } else {
- m_activeCall.reset();
}
-
- return RES_OK;
- }
-
- Result CallManager::updateHeldCall(cm_call_data_h held)
- {
- if (held) {
- m_heldCall = HeldCall::newInstance(*this, held);
- if (!m_heldCall) {
- LOG_RETURN(RES_FAIL, "HeldCall::newInstance() failed!");
- }
- } else {
- m_heldCall.reset();
- }
-
- return RES_OK;
- }
-
- Result CallManager::updateEndCall(cm_call_data_h end, SimSlot slot)
- {
- if (end) {
- m_endCall = EndCall::newInstance(*this, end, slot);
- if (!m_endCall) {
- LOG_RETURN(RES_FAIL, "EndCall::newInstance() failed!");
- }
- } else {
- m_endCall.reset();
- }
-
return RES_OK;
}
return m_callClient;
}
- ICallDialerWRef CallManager::getDialer()
+ SimSlot CallManager::getSimSlot() const
{
- return m_dialer;
+ return m_slot;
}
IIncomingCallWRef CallManager::getIncomingCall()
return m_endCall;
}
- void CallManager::addCallStateHandler(CallStateHandler handler)
+ Result CallManager::dialVoiceCall(const std::string &number)
{
- m_event += handler;
- }
+ char buff[TEL_NUMBER_MAX_SIZE] = { 0 };
+ snprintf(buff, sizeof(buff), "%s", number.c_str());
- void CallManager::removeCallStateHandler(CallStateHandler handler)
- {
- m_event -= handler;
+ return convertCMResult(
+ cm_dial_call(*m_callClient, buff, CM_CALL_TYPE_VOICE, convertCUISimSlot(m_slot)));
}
Result CallManager::endCall(unsigned int callId, CallReleaseType type)
return m_rejectMsgProvider;
}
- Result CallManager::processEndCallEvent(cm_call_event_data_h callEventData, SimSlot simSlot)
+ Result CallManager::processEndCallEvent(cm_call_event_data_h callEventData)
{
unsigned int callId = 0;
FAIL_RETURN(convertCMResult(
Result res = RES_OK;
if (m_incomingCall && callId == m_incomingCall->getInfo()->getCallId()) {
- res = updateEndCall(m_incomingCall->getCallData(), simSlot);
+ res = updateCall(m_endCall, m_incomingCall->getInfo());
m_incomingCall.reset();
} else if (m_activeCall && callId == m_activeCall->getInfo()->getCallId()) {
- res = updateEndCall(m_activeCall->getCallData(), simSlot);
+ res = updateCall(m_endCall, m_activeCall->getInfo());
m_activeCall.reset();
} else if (m_heldCall && callId == m_heldCall->getInfo()->getCallId()) {
- res = updateEndCall(m_heldCall->getCallData(), simSlot);
+ res = updateCall(m_endCall, m_heldCall->getInfo());
m_heldCall.reset();
} else if (m_activeCall && m_activeCall->getInfo()->getConferenceMemberCount() > 1) {
- res = updateEndCall(m_activeCall->getCallData(), simSlot);
+ res = updateCall(m_endCall, m_activeCall->getInfo());
m_activeCall.reset();
} else if (m_heldCall && m_heldCall->getInfo()->getConferenceMemberCount() > 1) {
- res = updateEndCall(m_heldCall->getCallData(), simSlot);
+ res = updateCall(m_endCall, m_heldCall->getInfo());
m_heldCall.reset();
}
return res;
}
- Result CallManager::processCommonCallEvent(cm_call_event_data_h callEventData, CallEventType type, SimSlot simSlot)
+ Result CallManager::processCommonCallEvent(cm_call_event_data_h callEventData, CallEventType type)
{
unsigned int callId = 0;
cm_call_data_h cmIncom = nullptr;
cm_call_event_data_get_held_call(callEventData, &cmHeld)),
"cm_call_event_data_get_held_call() failed!");
- if (type == CallEventType::INCOMING) {
- FAIL_RETURN(updateIncomingCall(cmIncom, simSlot), "updateIncomingCall() failed!");
- } else if (!cmIncom) {
- m_incomingCall.reset();
- }
- FAIL_RETURN(updateActiveCall(cmActive), "updateActiveCall() failed!");
- FAIL_RETURN(updateHeldCall(cmHeld), "updateHeldCall() failed!");
+ FAIL_RETURN(updateCall(m_incomingCall, cmIncom), "updateCall() failed!");
+ FAIL_RETURN(updateCall(m_activeCall, cmActive), "updateCall() failed!");
+ FAIL_RETURN(updateCall(m_heldCall, cmHeld), "updateCall() failed!");
return RES_OK;
}
void CallManager::callEventCb(cm_call_event_e callEvent, cm_call_event_data_h callEventData)
{
+ m_waitDialing = false;
+
if (!callEventData) {
ELOG("callEventData is NULL");
return;
DLOG("Call event changed on [%d]", type);
- cm_multi_sim_slot_type_e cmSimSlot;
- FAIL_RETURN_VOID(convertCMResult(
- cm_call_event_data_get_sim_slot(callEventData, &cmSimSlot)),
- "cm_call_event_data_get_sim_slot() failed!");
- SimSlot simSlot = convertCMSimSlot(cmSimSlot);
+ if (m_slot == SimSlot::UNDEFINED) {
+ cm_multi_sim_slot_type_e cmSimSlot;
+ FAIL_RETURN_VOID(convertCMResult(
+ cm_call_event_data_get_sim_slot(callEventData, &cmSimSlot)),
+ "cm_call_event_data_get_sim_slot() failed!");
+ m_slot = convertCMSimSlot(cmSimSlot);
+ }
m_endCall.reset();
switch (type) {
case CallEventType::END:
- FAIL_RETURN_VOID(processEndCallEvent(callEventData, simSlot),
+ FAIL_RETURN_VOID(processEndCallEvent(callEventData),
"processEndCallEvent() failed!");
case CallEventType::ACTIVE:
case CallEventType::INCOMING:
case CallEventType::SWAPPED:
case CallEventType::JOIN:
case CallEventType::SPLIT:
- FAIL_RETURN_VOID(processCommonCallEvent(callEventData, type, simSlot),
+ FAIL_RETURN_VOID(processCommonCallEvent(callEventData, type),
"processCommonCallEvent() failed!");
break;
default:
return;
}
- m_event.invoke(type);
+ if (m_listener) {
+ m_listener->onCallEvent(type);
+ }
+ }
+
+ void CallManager::dialStatusCb(cm_dial_status_e status)
+ {
+ m_waitDialing = false;
+
+ CallManagerErr err = convertCMDialStatusIntoErr(status);
+ if (err != CallManagerErr::NONE && m_listener) {
+ m_listener->onError(err);
+ }
+ }
+
+ Result CallManager::processOutgoingCall(const std::string &telNum)
+ {
+ if (!m_waitDialing) {
+ m_waitDialing = true;
+ return dialVoiceCall(telNum);
+ }
+ return RES_FAIL;
+ }
+
+ Result CallManager::processIncomingCall(SimSlot slot)
+ {
+ if (m_incomingCall) {
+ if (m_slot == SimSlot::UNDEFINED) {
+ m_slot = slot;
+ }
+ if (m_listener) {
+ m_listener->onCallEvent(CallEventType::INCOMING);
+ }
+ return RES_OK;
+ }
+ ELOG("Incoming call is NULL");
+ return RES_FAIL;
}
}
#include <call-manager-ext.h>
-#include "ucl/misc/Event.h"
-
#include "model/ICallManager.h"
#include "implTypes.h"
class CallManager final : public ICallManager {
public:
- static CallManagerSRef newInstance(const CallClientSRef &callClient);
+ static CallManagerSRef newInstance(const CallClientSRef &callClient,
+ ICallManagerListenerWRef listener);
virtual ~CallManager();
CallClientSRef getCallClient();
+ SimSlot getSimSlot() const;
+ ucl::Result dialVoiceCall(const std::string &number);
ucl::Result endCall(unsigned int callId, CallReleaseType type);
ucl::Result splitCalls(CallInfoSRef callInfo,
const IConferenceCallInfoSCRef &confCallInfo);
RejectMsgProviderSRef getRejectMsgProvider();
+ ucl::Result processOutgoingCall(const std::string &telNum);
+ ucl::Result processIncomingCall(SimSlot slot);
+
// ICallManager
- virtual ICallDialerWRef getDialer() override final;
virtual IIncomingCallWRef getIncomingCall() override final;
virtual IActiveCallWRef getActiveCall() override final;
virtual IHeldCallWRef getHeldCall() override final;
virtual IEndCallWRef getEndCall() override final;
- virtual void addCallStateHandler(CallStateHandler handler) override final;
- virtual void removeCallStateHandler(CallStateHandler handler) override final;
private:
friend class ucl::RefCountObj<CallManager>;
- CallManager(const CallClientSRef &callClient);
+ CallManager(const CallClientSRef &callClient,
+ ICallManagerListenerWRef listener);
ucl::Result prepare();
ucl::Result initCalls();
- ucl::Result updateIncomingCall(cm_call_data_h incom, SimSlot slot = SimSlot::DEFAULT);
- ucl::Result updateActiveCall(cm_call_data_h active);
- ucl::Result updateHeldCall(cm_call_data_h active);
- ucl::Result updateEndCall(cm_call_data_h end, SimSlot slot = SimSlot::DEFAULT);
- ucl::Result processEndCallEvent(cm_call_event_data_h callEventData, SimSlot slot);
+
+ template <class TYPE, class TYPE2>
+ ucl::Result updateCall(ucl::SharedRef<TYPE> &call, TYPE2 &&data);
+
+ ucl::Result processEndCallEvent(cm_call_event_data_h callEventData);
ucl::Result processCommonCallEvent(cm_call_event_data_h callEventData,
- CallEventType type, SimSlot simSlot);
+ CallEventType type);
void callEventCb(cm_call_event_e call_event, cm_call_event_data_h call_state_data);
+ void dialStatusCb(cm_dial_status_e status);
private:
CallClientSRef m_callClient;
RejectMsgProviderSRef m_rejectMsgProvider;
- CallDialerSRef m_dialer;
+ MsgClientSRef m_msgClient;
+ ICallManagerListenerWRef m_listener;
IncomingCallSRef m_incomingCall;
ActiveCallSRef m_activeCall;
HeldCallSRef m_heldCall;
EndCallSRef m_endCall;
- CallStateEvent m_event;
+ SimSlot m_slot;
+ bool m_waitDialing;
};
}
#include "CallClient.h"
#include "CallManager.h"
#include "CallInfo.h"
-#include "model/ICallDialer.h"
#include "common.h"
using namespace ucl;
- EndCall::EndCall(CallManager &cm, cm_call_data_h callData, SimSlot slot):
- BaseCall(callData),
+ EndCall::EndCall(CallManager &cm, ICallInfoSCRef callInfo):
m_cm(cm),
- m_slot(slot)
+ m_callInfo(callInfo)
{
}
{
}
- EndCallSRef EndCall::newInstance(CallManager &cm, cm_call_data_h callData, SimSlot slot)
+ EndCallSRef EndCall::newInstance(CallManager &cm, ICallInfoSCRef callInfo)
{
- if (!callData) {
- LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
+ if (!callInfo) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "callInfo is NULL");
}
-
- auto result = makeShared<EndCall>(cm, callData, slot);
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
- return result;
- }
-
- Result EndCall::prepare()
- {
- m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), m_callData);
- if (!m_callInfo) {
- LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
- }
- return RES_OK;
+ return makeShared<EndCall>(cm, callInfo);
}
ICallInfoSCRef EndCall::getInfo() const
Result EndCall::callBack()
{
- ICallDialerWRef dialer = m_cm.getDialer();
- if (dialer) {
- return dialer->dialVoiceCall(m_callInfo->getPhoneNumber(), m_slot);
- } else {
- return RES_FAIL;
- }
+ return m_cm.dialVoiceCall(m_callInfo->getPhoneNumber());
}
Result EndCall::writeMessage()
#include <call-manager-ext.h>
-#include "BaseCall.h"
#include "model/IEndCall.h"
#include "implTypes.h"
class CallManager;
- class EndCall final :
- public BaseCall,
- public IEndCall {
+ class EndCall final : public IEndCall {
public:
- static EndCallSRef newInstance(CallManager &cm,
- cm_call_data_h callData,
- SimSlot slot = SimSlot::DEFAULT);
+ static EndCallSRef newInstance(CallManager &cm, ICallInfoSCRef callInfo);
virtual ~EndCall();
private:
friend class ucl::RefCountObj<EndCall>;
- EndCall(CallManager &cm, cm_call_data_h callData, SimSlot slot);
+ EndCall(CallManager &cm, ICallInfoSCRef callInfo);
ucl::Result prepare();
private:
CallManager &m_cm;
- CallInfoSRef m_callInfo;
- SimSlot m_slot;
+ ICallInfoSCRef m_callInfo;
};
}
using namespace ucl;
HeldCall::HeldCall(CallManager &cm, cm_call_data_h callData):
- BaseCall(callData),
m_cm(cm)
{
}
}
auto result = makeShared<HeldCall>(cm, callData);
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
return result;
}
- Result HeldCall::prepare()
+ Result HeldCall::prepare(cm_call_data_h callData)
{
- m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), m_callData);
+ m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), callData);
if (!m_callInfo) {
LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
}
#include <call-manager-ext.h>
-#include "BaseCall.h"
#include "model/IHeldCall.h"
#include "implTypes.h"
namespace callui {
- class HeldCall final :
- public BaseCall,
- public IHeldCall {
+ class HeldCall final : public IHeldCall {
public:
static HeldCallSRef newInstance(CallManager &cm, cm_call_data_h callData);
virtual ~HeldCall();
friend class ucl::RefCountObj<HeldCall>;
HeldCall(CallManager &cm, cm_call_data_h callData);
- ucl::Result prepare();
+ ucl::Result prepare(cm_call_data_h callData);
private:
CallManager &m_cm;
using namespace ucl;
- IncomingCall::IncomingCall(CallManager &cm, cm_call_data_h callData, SimSlot slot):
- BaseCall(callData),
- m_cm(cm),
- m_simSlot(slot)
+ IncomingCall::IncomingCall(CallManager &cm, cm_call_data_h callData):
+ m_cm(cm)
{
}
{
}
- IncomingCallSRef IncomingCall::newInstance(CallManager &cm, cm_call_data_h callData, SimSlot slot)
+ IncomingCallSRef IncomingCall::newInstance(CallManager &cm, cm_call_data_h callData)
{
if (!callData) {
LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
}
- auto result = makeShared<IncomingCall>(cm, callData, slot);
- FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ auto result = makeShared<IncomingCall>(cm, callData);
+ FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
return result;
}
- Result IncomingCall::prepare()
+ Result IncomingCall::prepare(cm_call_data_h callData)
{
- m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), m_callData);
+ m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), callData);
if (!m_callInfo) {
LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
}
if (!msg) {
LOG_RETURN(RES_FAIL, "message is not RejectMsg type!");
}
- return msg->send(m_callInfo->getPhoneNumber(), m_simSlot);
+ return msg->send(m_callInfo->getPhoneNumber(), m_cm.getSimSlot());
+
}
Result IncomingCall::stopAlert()
#include <call-manager-ext.h>
-#include "BaseCall.h"
#include "model/IIncomingCall.h"
#include "implTypes.h"
namespace callui {
- class IncomingCall final :
- public BaseCall,
- public IIncomingCall {
+ class IncomingCall final : public IIncomingCall {
public:
- static IncomingCallSRef newInstance(CallManager &cm,
- cm_call_data_h callData,
- SimSlot slot = SimSlot::DEFAULT);
+ static IncomingCallSRef newInstance(CallManager &cm, cm_call_data_h callData);
virtual ~IncomingCall();
private:
friend class ucl::RefCountObj<IncomingCall>;
- IncomingCall(CallManager &cm, cm_call_data_h callData, SimSlot slot);
+ IncomingCall(CallManager &cm, cm_call_data_h callData);
- ucl::Result prepare();
+ ucl::Result prepare(cm_call_data_h callData);
private:
CallManager &m_cm;
CallInfoSRef m_callInfo;
- SimSlot m_simSlot;
};
}
AudioStateType convertCMAudioState(cm_audio_state_type_e state);
- DialStatus convertCMDialStatus(cm_dial_status_e status);
+ CallManagerErr convertCMDialStatusIntoErr(cm_dial_status_e status);
cm_multi_sim_slot_type_e convertCUISimSlot(SimSlot slot);
}
}
- inline DialStatus convertCMDialStatus(cm_dial_status_e status)
+ inline CallManagerErr convertCMDialStatusIntoErr(cm_dial_status_e status)
{
switch (status) {
- case CM_DIAL_SUCCESS: return DialStatus::SUCCESS;
- case CM_DIAL_CANCEL: return DialStatus::CANCEL;
- case CM_DIAL_FAIL: return DialStatus::FAIL;
- case CM_DIAL_FAIL_SS: return DialStatus::FAIL_SS;
- case CM_DIAL_FAIL_FDN: return DialStatus::FAIL_FDN;
- case CM_DIAL_FAIL_FLIGHT_MODE: return DialStatus::FLIGHT_MODE;
+ case CM_DIAL_SUCCESS: return CallManagerErr::NONE;
+ case CM_DIAL_CANCEL: return CallManagerErr::DIAL_CANCEL;
+ case CM_DIAL_FAIL: return CallManagerErr::DIAL_FAIL;
+ case CM_DIAL_FAIL_SS: return CallManagerErr::DIAL_FAIL_SS;
+ case CM_DIAL_FAIL_FDN: return CallManagerErr::DIAL_FAIL_FDN;
+ case CM_DIAL_FAIL_FLIGHT_MODE: return CallManagerErr::DIAL_FLIGHT_MODE;
default:
- return DialStatus::FAIL;
+ return CallManagerErr::DIAL_FAIL;
}
}
UCL_DECLARE_REF_ALIASES(SoundManager);
UCL_DECLARE_REF_ALIASES(CallManager);
- UCL_DECLARE_REF_ALIASES(CallDialer);
UCL_DECLARE_REF_ALIASES(IncomingCall);
UCL_DECLARE_REF_ALIASES(ActiveCall);
UCL_DECLARE_REF_ALIASES(RejectMsgProvider);
UCL_DECLARE_REF_ALIASES(RejectMsg);
- using CallStateEvent = ucl::Event<CallStateHandler>;
using AudioStateEvent = ucl::Event<AudioStateHandler>;
using MuteStateEvent = ucl::Event<MuteStateHandler>;
- using DialStatusEvent = ucl::Event<DialStatusHandler>;
}
#endif // __CALLUI_MODEL_IMPL_TYPES_H__
<ui-application appid="org.tizen.call-ui" exec="call-ui" multiple="false" nodisplay="false" taskmanage="true" type="capp">
<label>call-ui</label>
<icon>call-ui.png</icon>
+ <app-control>
+ <operation name="http://tizen.org/appcontrol/operation/call"/>
+ <uri name="tel"/>
+ </app-control>
+ <metadata key="http://tizen.org/metadata/background-category/media"/>
+ <metadata key="http://tizen.org/metadata/background-category/background-network"/>
</ui-application>
<privileges>
<privilege>http://tizen.org/privilege/keygrab</privilege>