From 1bad70e483b1820d73695e8d213c003b396ab9fd Mon Sep 17 00:00:00 2001 From: Igor Olshevskyi Date: Tue, 18 Apr 2017 17:10:51 +0300 Subject: [PATCH] TizenRefApp-8402 [Call UI] Add ICall public interface Change-Id: I849e098f617a6af8d17fe982c346732f544cfd95 --- inc/main/Instance.h | 6 +-- inc/model/CallBuilder.h | 36 +++++++++++++++ inc/model/ICall.h | 35 ++++++++++++++ inc/model/ICallListener.h | 32 +++++++++++++ inc/model/types.h | 20 ++++---- inc/types.h | 1 + src/main/Instance.cpp | 32 +++++++------ src/model/Call.cpp | 56 ++++++++++++++--------- {inc => src}/model/Call.h | 37 ++++++++------- src/model/CallBuilder.cpp | 45 ++++++++++++++++++ src/model/CallManager.cpp | 29 ++++++++++-- {inc => src}/model/ICallManagerListener.h | 2 +- src/model/helpers.h | 2 - src/model/helpers.hpp | 14 ------ src/model/implTypes.h | 11 +++++ 15 files changed, 270 insertions(+), 88 deletions(-) create mode 100644 inc/model/CallBuilder.h create mode 100644 inc/model/ICall.h create mode 100644 inc/model/ICallListener.h rename {inc => src}/model/Call.h (60%) create mode 100644 src/model/CallBuilder.cpp rename {inc => src}/model/ICallManagerListener.h (97%) diff --git a/inc/main/Instance.h b/inc/main/Instance.h index 5302e33..40b2b54 100644 --- a/inc/main/Instance.h +++ b/inc/main/Instance.h @@ -24,7 +24,7 @@ #include "ucl/appfw/SysEventProvider.h" -#include "model/Call.h" +#include "model/ICall.h" namespace callui { @@ -37,7 +37,7 @@ namespace callui { // For testing ucl::WindowWRef getWindow(); ucl::IInstanceContext *getContext(); - CallWRef getCall(); + ICallWRef getCall(); // IInstance // @@ -58,7 +58,7 @@ namespace callui { ucl::SysEventProvider &m_sysEventProvider; ucl::IInstanceContext *m_context; ucl::WindowSRef m_win; - CallSRef m_call; + ICallSRef m_call; }; } diff --git a/inc/model/CallBuilder.h b/inc/model/CallBuilder.h new file mode 100644 index 0000000..b603cd1 --- /dev/null +++ b/inc/model/CallBuilder.h @@ -0,0 +1,36 @@ +/* + * 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_BUILDER_H__ +#define CALLUI_MODEL_CALL_BUILDER_H__ + +#include "types.h" + +namespace callui { + + class CallBuilder { + public: + CallBuilder(); + CallBuilder &setListener(ICallListenerWRef value); + ICallSRef build() const; + + private: + ICallListenerWRef m_listener; + }; + +} + +#endif // CALLUI_MODEL_CALL_BUILDER_H__ diff --git a/inc/model/ICall.h b/inc/model/ICall.h new file mode 100644 index 0000000..c5fcf5b --- /dev/null +++ b/inc/model/ICall.h @@ -0,0 +1,35 @@ +/* + * 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_H__ +#define __CALLUI_MODEL_I_CALL_H__ + +#include + +#include "types.h" + +namespace callui { + + class ICall : public ucl::Polymorphic { + public: + virtual ucl::Result processAppControl(app_control_h appControl) = 0; + virtual ISoundManagerSRef getSoundManager() = 0; + virtual ICallManagerSRef getCallManager() = 0; + }; + +} + +#endif // __CALLUI_MODEL_I_CALL_H__ diff --git a/inc/model/ICallListener.h b/inc/model/ICallListener.h new file mode 100644 index 0000000..0c72b73 --- /dev/null +++ b/inc/model/ICallListener.h @@ -0,0 +1,32 @@ +/* + * 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_LISTENER_H__ +#define __CALLUI_MODEL_I_CALL_LISTENER_H__ + +#include "types.h" + +namespace callui { + + class ICallListener : public ucl::Polymorphic { + public: + virtual void onCallEvent(CallEventType type) = 0; + virtual void onError(CallErr err) = 0; + }; + +} + +#endif // __CALLUI_MODEL_I_CALL_LISTENER_H__ diff --git a/inc/model/types.h b/inc/model/types.h index 2b86f22..41eac45 100644 --- a/inc/model/types.h +++ b/inc/model/types.h @@ -23,6 +23,12 @@ namespace callui { + enum class CallErr { + DIAL_CANCEL, + DIAL_FAIL, + DIAL_FLIGHT_MODE + }; + enum class SimSlot { UNDEFINED, FIRST, @@ -30,15 +36,6 @@ namespace callui { 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, @@ -87,13 +84,12 @@ namespace callui { NAME }; - UCL_DECLARE_REF_ALIASES(Call); + UCL_DECLARE_REF_ALIASES(ICall); + UCL_DECLARE_REF_ALIASES(ICallListener); UCL_DECLARE_REF_ALIASES(ICallManager); UCL_DECLARE_REF_ALIASES(ISoundManager); - UCL_DECLARE_REF_ALIASES(ICallManagerListener); - UCL_DECLARE_REF_ALIASES(IIncomingCall); UCL_DECLARE_REF_ALIASES(IActiveCall); UCL_DECLARE_REF_ALIASES(IHeldCall); diff --git a/inc/types.h b/inc/types.h index 75a622c..fcccaaa 100644 --- a/inc/types.h +++ b/inc/types.h @@ -22,6 +22,7 @@ #include "ucl/util/types.h" #include "ucl/util/memory.h" #include "ucl/util/delegation.h" +#include "ucl/misc/RefCountAware.h" namespace callui { enum { diff --git a/src/main/Instance.cpp b/src/main/Instance.cpp index e2fbeff..339120c 100644 --- a/src/main/Instance.cpp +++ b/src/main/Instance.cpp @@ -21,15 +21,16 @@ #include #include -#include "../common.h" - +#include "model/CallBuilder.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" +#include "model/ICallListener.h" + +#include "../common.h" namespace callui { @@ -37,16 +38,17 @@ namespace callui { // For testing UCL_DECLARE_REF_ALIASES(Listener); - class Listener : public ICallManagerListener { + class Listener : public ICallListener { public: static ListenerSRef newInstance(Instance &instance) { return makeShared(instance); } + virtual void onCallEvent(CallEventType type) override final { WindowWRef win = m_instance.getWindow(); - CallWRef call = m_instance.getCall(); + ICallWRef call = m_instance.getCall(); ICallManagerSRef callMng = {}; if (call) { callMng = call->getCallManager(); @@ -103,12 +105,19 @@ namespace callui { } } - virtual void onError(CallManagerErr err) override final + virtual void onError(CallErr err) override final { ILOG(); } private: + friend class ucl::RefCountObj; + Listener(Instance &instance): + m_instance(instance) + { + ILOG(); + } + void logCallInfo(ICallInfoSCRef info) { ILOG("* call id [%d]", info->getCallId()); @@ -116,13 +125,6 @@ namespace callui { ILOG("* conference member count [%d]", info->getConferenceMemberCount()); } - private: - friend class ucl::RefCountObj; - Listener(Instance &instance): - m_instance(instance) - { - ILOG(); - } private: Instance &m_instance; }; @@ -147,7 +149,7 @@ namespace callui { // For testing static ListenerSRef listener = Listener::newInstance(*this); - m_call = Call::Builder(). + m_call = CallBuilder(). setListener(listener). build(); @@ -225,7 +227,7 @@ namespace callui { return m_context; } - CallWRef Instance::getCall() + ICallWRef Instance::getCall() { return m_call; } diff --git a/src/model/Call.cpp b/src/model/Call.cpp index 327fefa..68d9d67 100644 --- a/src/model/Call.cpp +++ b/src/model/Call.cpp @@ -14,13 +14,14 @@ * limitations under the License. */ -#include "model/Call.h" +#include "Call.h" #include #include "CallClient.h" #include "CallManager.h" #include "SoundManager.h" +#include "model/ICallListener.h" #include "common.h" @@ -28,25 +29,9 @@ namespace callui { using namespace ucl; - Call::Builder::Builder(): - m_listener(nullptr) - { - } - - Call::Builder &Call::Builder::setListener(ICallManagerListenerWRef value) - { - m_listener = value; - return *this; - } - - CallSRef Call::Builder::build() const - { - auto result = makeShared(); - FAIL_RETURN_VALUE(result->prepare(m_listener), {}, "result->prepare() failed!"); - return result; - } - - Call::Call() + Call::Call(RefCountObjBase &rc, ICallListenerWRef listener): + RefCountAware(&rc), + m_listener(listener) { } @@ -124,14 +109,14 @@ namespace callui { return ret; } - Result Call::prepare(ICallManagerListenerWRef listener) + Result Call::prepare() { CallClientSRef callClient = CallClient::newInstance(); if (!callClient) { LOG_RETURN(RES_FAIL, "Client::newInstance() failed!"); } - m_callManager = CallManager::newInstance(callClient, listener); + m_callManager = CallManager::newInstance(callClient, asWeak(*this)); if (!m_callManager) { LOG_RETURN(RES_FAIL, "CallManager::newInstance() failed!"); } @@ -154,4 +139,31 @@ namespace callui { return m_soundManager; } + void Call::onCallEvent(CallEventType type) + { + if (m_listener) { + m_listener->onCallEvent(type); + } + } + + void Call::onError(CallManagerErr err) + { + CallErr callErr = CallErr::DIAL_FAIL; + switch (err) { + case CallManagerErr::DIAL_CANCEL: + callErr = CallErr::DIAL_CANCEL; + break; + case CallManagerErr::DIAL_FLIGHT_MODE: + callErr = CallErr::DIAL_FLIGHT_MODE; + break; + default: + callErr = CallErr::DIAL_FAIL; + break; + } + + if (m_listener) { + m_listener->onError(callErr); + } + } + } diff --git a/inc/model/Call.h b/src/model/Call.h similarity index 60% rename from inc/model/Call.h rename to src/model/Call.h index 5acb364..2754e79 100644 --- a/inc/model/Call.h +++ b/src/model/Call.h @@ -17,6 +17,9 @@ #ifndef __CALLUI_MODEL_CALL_H__ #define __CALLUI_MODEL_CALL_H__ +#include "model/ICall.h" +#include "ICallManagerListener.h" + #include #include "types.h" @@ -26,33 +29,35 @@ namespace callui { UCL_DECLARE_REF_ALIASES(CallManager); UCL_DECLARE_REF_ALIASES(SoundManager); - class Call final : public ucl::NonCopyable { - public: - class Builder { - public: - Builder(); - Builder &setListener(ICallManagerListenerWRef value); - CallSRef build() const; - private: - ICallManagerListenerWRef m_listener; - }; - + class Call final : + public ucl::RefCountAware, + public ICall, + public ICallManagerListener { public: virtual ~Call(); - ucl::Result processAppControl(app_control_h appControl); - ISoundManagerSRef getSoundManager(); - ICallManagerSRef getCallManager(); + // ICall + + virtual ucl::Result processAppControl(app_control_h appControl) override final; + virtual ISoundManagerSRef getSoundManager() override final; + virtual ICallManagerSRef getCallManager() override final; + + // ICallManagerListener + + virtual void onCallEvent(CallEventType type) override final; + virtual void onError(CallManagerErr err) override final; private: + friend class CallBuilder; friend class ucl::RefCountObj; - Call(); + Call(ucl::RefCountObjBase &rc, ICallListenerWRef listener); - ucl::Result prepare(ICallManagerListenerWRef listener); + ucl::Result prepare(); private: CallManagerSRef m_callManager; SoundManagerSRef m_soundManager; + ICallListenerWRef m_listener; }; } diff --git a/src/model/CallBuilder.cpp b/src/model/CallBuilder.cpp new file mode 100644 index 0000000..6d2b9bf --- /dev/null +++ b/src/model/CallBuilder.cpp @@ -0,0 +1,45 @@ +/* + * 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 "model/CallBuilder.h" + +#include "Call.h" + +#include "common.h" + +namespace callui { + + using namespace ucl; + + CallBuilder::CallBuilder(): + m_listener(nullptr) + { + } + + CallBuilder &CallBuilder::setListener(ICallListenerWRef value) + { + m_listener = value; + return *this; + } + + ICallSRef CallBuilder::build() const + { + auto result = makeShared(m_listener); + FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!"); + return result; + } + +} diff --git a/src/model/CallManager.cpp b/src/model/CallManager.cpp index ab507a5..d8a49ec5 100644 --- a/src/model/CallManager.cpp +++ b/src/model/CallManager.cpp @@ -16,7 +16,7 @@ #include "CallManager.h" -#include "model/ICallManagerListener.h" +#include "ICallManagerListener.h" #include "CallClient.h" #include "RejectMsgProvider.h" @@ -286,8 +286,31 @@ namespace callui { { m_waitDialing = false; - CallManagerErr err = convertCMDialStatusIntoErr(status); - if (err != CallManagerErr::NONE && m_listener) { + CallManagerErr err = CallManagerErr::DIAL_FAIL; + switch (status) { + case CM_DIAL_SUCCESS: + return; + case CM_DIAL_CANCEL: + err = CallManagerErr::DIAL_CANCEL; + break; + case CM_DIAL_FAIL: + err = CallManagerErr::DIAL_FAIL; + break; + case CM_DIAL_FAIL_SS: + err = CallManagerErr::DIAL_FAIL_SS; + break; + case CM_DIAL_FAIL_FDN: + err = CallManagerErr::DIAL_FAIL_FDN; + break; + case CM_DIAL_FAIL_FLIGHT_MODE: + err = CallManagerErr::DIAL_FLIGHT_MODE; + break; + default: + err = CallManagerErr::DIAL_FAIL; + break; + } + + if (m_listener) { m_listener->onError(err); } } diff --git a/inc/model/ICallManagerListener.h b/src/model/ICallManagerListener.h similarity index 97% rename from inc/model/ICallManagerListener.h rename to src/model/ICallManagerListener.h index f3433ad..5d66a7c 100644 --- a/inc/model/ICallManagerListener.h +++ b/src/model/ICallManagerListener.h @@ -17,7 +17,7 @@ #ifndef __CALLUI_MODEL_I_CALL_MANAGER_LISTENER_H__ #define __CALLUI_MODEL_I_CALL_MANAGER_LISTENER_H__ -#include "types.h" +#include "implTypes.h" namespace callui { diff --git a/src/model/helpers.h b/src/model/helpers.h index 66f5a53..2f11b91 100644 --- a/src/model/helpers.h +++ b/src/model/helpers.h @@ -28,8 +28,6 @@ namespace callui { AudioStateType convertCMAudioState(cm_audio_state_type_e state); - CallManagerErr convertCMDialStatusIntoErr(cm_dial_status_e status); - cm_multi_sim_slot_type_e convertCUISimSlot(SimSlot slot); SimSlot convertCMSimSlot(cm_multi_sim_slot_type_e slot); diff --git a/src/model/helpers.hpp b/src/model/helpers.hpp index d80b800..a6485e1 100644 --- a/src/model/helpers.hpp +++ b/src/model/helpers.hpp @@ -47,20 +47,6 @@ namespace callui { } } - inline CallManagerErr convertCMDialStatusIntoErr(cm_dial_status_e status) - { - switch (status) { - 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 CallManagerErr::DIAL_FAIL; - } - } - inline cm_multi_sim_slot_type_e convertCUISimSlot(SimSlot slot) { switch (slot) { diff --git a/src/model/implTypes.h b/src/model/implTypes.h index e1e185c..4b5536c 100644 --- a/src/model/implTypes.h +++ b/src/model/implTypes.h @@ -29,11 +29,21 @@ namespace callui { ALL_ACTIVE }; + enum class CallManagerErr { + DIAL_CANCEL, + DIAL_FAIL, + DIAL_FAIL_SS, + DIAL_FAIL_FDN, + DIAL_FLIGHT_MODE + }; + UCL_DECLARE_REF_ALIASES(CallClient); UCL_DECLARE_REF_ALIASES(SoundManager); UCL_DECLARE_REF_ALIASES(CallManager); + UCL_DECLARE_REF_ALIASES(ICallManagerListener); + UCL_DECLARE_REF_ALIASES(IncomingCall); UCL_DECLARE_REF_ALIASES(ActiveCall); UCL_DECLARE_REF_ALIASES(HeldCall); @@ -49,6 +59,7 @@ namespace callui { using AudioStateEvent = ucl::Event; using MuteStateEvent = ucl::Event; + } #endif // __CALLUI_MODEL_IMPL_TYPES_H__ -- 2.34.1