From: Igor Olshevskyi Date: Mon, 24 Jul 2017 06:46:15 +0000 (+0300) Subject: TizenRefApp-8916 [Call UI] Rename main model class Call on CallUI X-Git-Tag: submit/tizen/20170811.141832^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F140198%2F1;p=profile%2Fwearable%2Fapps%2Fnative%2Fcall-ui.git TizenRefApp-8916 [Call UI] Rename main model class Call on CallUI Change-Id: I7b977ecfe3bd7d796da0e116e89dfc87ba3f820d --- diff --git a/inc/model/CallBuilder.h b/inc/model/CallBuilder.h deleted file mode 100644 index 1ade234..0000000 --- a/inc/model/CallBuilder.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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(); - ICallSRef build() const; - }; - -} - -#endif // __CALLUI_MODEL_CALL_BUILDER_H__ diff --git a/inc/model/CallUIBuilder.h b/inc/model/CallUIBuilder.h new file mode 100644 index 0000000..ddcb11e --- /dev/null +++ b/inc/model/CallUIBuilder.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_CALL_UI_BUILDER_H__ +#define __CALLUI_MODEL_CALL_UI_BUILDER_H__ + +#include "types.h" + +namespace callui { + + class CallUIBuilder { + public: + CallUIBuilder(); + ICallUISRef build() const; + }; + +} + +#endif // __CALLUI_MODEL_CALL_UI_BUILDER_H__ diff --git a/inc/model/ICall.h b/inc/model/ICall.h deleted file mode 100644 index 9cc6505..0000000 --- a/inc/model/ICall.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 void setListener(const ICallListenerWRef &listener) = 0; - virtual ucl::Result processAppControl(app_control_h appControl) = 0; - virtual ISoundManagerSRef getSoundManager() = 0; - virtual ICallManagerSRef getCallManager() = 0; - virtual IIndicatorStateProviderSRef getIndicatorStateProvider() = 0; - }; - -} - -#endif // __CALLUI_MODEL_I_CALL_H__ diff --git a/inc/model/ICallUI.h b/inc/model/ICallUI.h new file mode 100644 index 0000000..06deda1 --- /dev/null +++ b/inc/model/ICallUI.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_I_CALL_UI_H__ +#define __CALLUI_MODEL_I_CALL_UI_H__ + +#include + +#include "types.h" + +namespace callui { + + class ICallUI : public ucl::Polymorphic { + public: + virtual void setListener(const ICallListenerWRef &listener) = 0; + virtual ucl::Result processAppControl(app_control_h appControl) = 0; + virtual ISoundManagerSRef getSoundManager() = 0; + virtual ICallManagerSRef getCallManager() = 0; + virtual IIndicatorStateProviderSRef getIndicatorStateProvider() = 0; + }; +} + +#endif // __CALLUI_MODEL_I_CALL_UI_H__ diff --git a/inc/model/types.h b/inc/model/types.h index ea83dc2..3283943 100644 --- a/inc/model/types.h +++ b/inc/model/types.h @@ -140,7 +140,7 @@ namespace callui { HD_VOICE }; - UCL_DECLARE_REF_ALIASES(ICall); + UCL_DECLARE_REF_ALIASES(ICallUI); UCL_DECLARE_REF_ALIASES(ICallListener); UCL_DECLARE_REF_ALIASES(ICallManager); diff --git a/inc/presenters/Instance.h b/inc/presenters/Instance.h index ea8afab..0c15077 100644 --- a/inc/presenters/Instance.h +++ b/inc/presenters/Instance.h @@ -59,7 +59,7 @@ namespace callui { ucl::SysEventProvider &m_sysEventProvider; ucl::IInstanceContext *m_context; - ICallSRef m_call; + ICallUISRef m_call; ucl::WindowSRef m_win; ucl::NaviframeSRef m_navi; diff --git a/inc/presenters/MainPage.h b/inc/presenters/MainPage.h index 4d9443a..6366dea 100644 --- a/inc/presenters/MainPage.h +++ b/inc/presenters/MainPage.h @@ -36,11 +36,11 @@ namespace callui { Builder(); ~Builder(); Builder &setNaviframe(const ucl::NaviframeSRef &navi); - Builder &setCall(const ICallSRef &call); + Builder &setCallUI(const ICallUISRef &call); MainPageSRef build(const ExitRequestHandler handler) const; private: ucl::NaviframeSRef m_navi; - ICallSRef m_call; + ICallUISRef m_call; }; private: @@ -48,7 +48,7 @@ namespace callui { MainPage(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi, const ExitRequestHandler handler, - const ICallSRef &call); + const ICallUISRef &call); virtual ~MainPage(); ucl::Result doPrepare(ucl::NaviItem &item); @@ -104,7 +104,7 @@ namespace callui { ucl::LayoutSRef m_rmLy; ucl::StyledWidgetSRef m_bottomBtn; - ICallSRef m_call; + ICallUISRef m_call; ICallManagerSRef m_cm; IndicatorPresenterSRef m_indicator; CallInfoPresenterSRef m_callInfoPrs; diff --git a/src/model/Call.cpp b/src/model/Call.cpp deleted file mode 100644 index e54cd56..0000000 --- a/src/model/Call.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/* - * 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 "Call.h" - -#include - -#include "model/ICallListener.h" -#include "model/IIncomingCall.h" -#include "model/IActiveCall.h" -#include "model/IHeldCall.h" -#include "model/IEndCall.h" -#include "model/ICallInfo.h" - -#include "CallClient.h" -#include "CallManager.h" -#include "SoundManager.h" - -#include "VoiceControlStateProvider.h" -#include "IndicatorStateProvider.h" - -#include "ConnectionStateSource.h" -#include "RssiStateSource.h" -#include "BatteryStateSource.h" -#include "VoiceControlStateSource.h" -#include "SimSlotStateSource.h" -#include "HdVoiceStateSource.h" - -#include "common.h" - -namespace callui { - - using namespace ucl; - - Call::Call(IRefCountObj &rc): - RefCountAware(&rc) - { - } - - Call::~Call() - { - } - - void Call::setListener(const ICallListenerWRef &listener) - { - m_listener = listener; - } - - 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(atoi(tmp)))); - - } else { - tmp = static_cast(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() - { - auto callClient = CallClient::newInstance(); - if (!callClient) { - LOG_RETURN(RES_FAIL, - "Client::newInstance() failed!"); - } - - m_callManager = CallManager::newInstance(callClient, asWeak(*this)); - if (!m_callManager) { - LOG_RETURN(RES_FAIL, - "CallManager::newInstance() failed!"); - } - - m_soundManager = SoundManager::newInstance(callClient); - if (!m_soundManager) { - LOG_RETURN(RES_FAIL, - "SoundManage::newInstance() failed!"); - } - - m_voiceControlPrv = VoiceControlStateProvider::newInstance(); - if (!m_voiceControlPrv) { - LOG_RETURN(RES_FAIL, - "VoiceControlStateProvider::newInstance() failed!"); - } - - FAIL_RETURN(initInidcatorStateProvider(), - "Init Indicator State Provider failed!"); - - return RES_OK; - } - - Result Call::initInidcatorStateProvider() - { - m_indicatorStPrv = IndicatorStateProvider::newInstance(); - if (!m_indicatorStPrv) { - LOG_RETURN(RES_FAIL, "IndicatorStateProvider::newInstance() failed!"); - } - - auto connStateSource = ConnectionStateSource::newInstance(); - if (!connStateSource) { - LOG_RETURN(RES_FAIL, - "ConnectionStateSource::newInstance() failed!"); - } - FAIL_RETURN(m_indicatorStPrv->setStateSource( - IndicatorProperty::NW_CONNECTION, connStateSource), - "setStateSource() failed!"); - - auto rssiStSrc = RssiStateSource::newInstance(); - if (!rssiStSrc) { - LOG_RETURN(RES_FAIL, - "RssiStateSource::newInstance() failed!"); - } - FAIL_RETURN(m_indicatorStPrv->setStateSource( - IndicatorProperty::RSSI, rssiStSrc), - "setStateSource() failed!"); - - auto batteryStSrc = BatteryStateSource::newInstance(); - if (!batteryStSrc) { - LOG_RETURN(RES_FAIL, - "BatteryStateSource::newInstance() failed!"); - } - FAIL_RETURN(m_indicatorStPrv->setStateSource( - IndicatorProperty::BATTERY, batteryStSrc), - "setStateSource() failed!"); - - auto voiceControlStSrc = - VoiceControlStateSource::newInstance(m_voiceControlPrv); - if (!voiceControlStSrc) { - LOG_RETURN(RES_FAIL, - "VoiceControlStateSource::newInstance() failed!"); - } - FAIL_RETURN(m_indicatorStPrv->setStateSource( - IndicatorProperty::VOICE_CONTROL, voiceControlStSrc), - "setStateSource() failed!"); - - m_simSlotStSrc = makeShared( - m_callManager->getSimSlot(), getForwardedCallStatus()); - FAIL_RETURN(m_indicatorStPrv->setStateSource( - IndicatorProperty::SIM_SLOT, m_simSlotStSrc), - "setStateSource() failed!"); - - m_hdCallStSrc = makeShared( - getHDVoiceStatus()); - FAIL_RETURN(m_indicatorStPrv->setStateSource( - IndicatorProperty::HD_VOICE, m_hdCallStSrc), - "setStateSource() failed!"); - - return RES_OK; - } - - ICallManagerSRef Call::getCallManager() - { - return m_callManager; - } - - ISoundManagerSRef Call::getSoundManager() - { - return m_soundManager; - } - - IIndicatorStateProviderSRef Call::getIndicatorStateProvider() - { - return m_indicatorStPrv; - } - - ICallInfoSCRef Call::getCurrentCallInfo() const - { - CallMask calls = m_callManager->getAvailableCalls(); - if (!calls) { - DLOG("No available calls"); - return {}; - } else if (calls & CALL_FLAG_INCOMING) { - return m_callManager->getIncomingCall()->getInfo(); - } else if (calls & CALL_FLAG_ACTIVE) { - return m_callManager->getActiveCall()->getInfo(); - } else if (calls & CALL_FLAG_HELD) { - return m_callManager->getHeldCall()->getInfo(); - } else if (calls & CALL_FLAG_END) { - return m_callManager->getEndCall()->getInfo(); - } - return {}; - } - - bool Call::getHDVoiceStatus() const - { - ICallInfoSCRef info = getCurrentCallInfo(); - if (info) { - return info->isHDVoice(); - } - return false; - } - - bool Call::getForwardedCallStatus() const - { - ICallInfoSCRef info = getCurrentCallInfo(); - if (info) { - return info->isForwarded(); - } - return false; - } - - void Call::updateHdVoiceStateSource() - { - m_hdCallStSrc->updateState(getHDVoiceStatus()); - } - - void Call::updateSimSlotStateSource() - { - m_simSlotStSrc->updateSimSlot(m_callManager->getSimSlot(), - getForwardedCallStatus()); - } - - void Call::onCallEvent(CallEventType type) - { - updateSimSlotStateSource(); - updateHdVoiceStateSource(); - - if (const auto listener = m_listener.lock()) { - listener->onCallEvent(type); - } - } - - void Call::onError(CallManagerErr err) - { - auto 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 (const auto listener = m_listener.lock()) { - listener->onError(callErr); - } - } - -} diff --git a/src/model/Call.h b/src/model/Call.h deleted file mode 100644 index cc18576..0000000 --- a/src/model/Call.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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_H__ -#define __CALLUI_MODEL_CALL_H__ - -#include "model/ICall.h" -#include "ICallManagerListener.h" - -#include - -#include "types.h" - -namespace callui { - - UCL_DECLARE_REF_ALIASES(CallManager); - UCL_DECLARE_REF_ALIASES(SoundManager); - - class Call final : - public ucl::RefCountAware, - public ICall, - public ICallManagerListener { - public: - virtual ~Call(); - - // ICall - - virtual void setListener(const ICallListenerWRef &listener) override final; - virtual ucl::Result processAppControl(app_control_h appControl) override final; - virtual ISoundManagerSRef getSoundManager() override final; - virtual ICallManagerSRef getCallManager() override final; - virtual IIndicatorStateProviderSRef getIndicatorStateProvider() override final; - - // ICallManagerListener - - virtual void onCallEvent(CallEventType type) override final; - virtual void onError(CallManagerErr err) override final; - - private: - friend class CallBuilder; - friend class ucl::ReffedObj; - Call(ucl::IRefCountObj &rc); - - ucl::Result prepare(); - - ucl::Result initInidcatorStateProvider(); - - void updateHdVoiceStateSource(); - void updateSimSlotStateSource(); - ICallInfoSCRef getCurrentCallInfo() const; - bool getHDVoiceStatus() const; - bool getForwardedCallStatus() const; - - private: - CallManagerSRef m_callManager; - SoundManagerSRef m_soundManager; - ICallListenerWRef m_listener; - SimSlotStateSourceSRef m_simSlotStSrc; - HdVoiceStateSourceSRef m_hdCallStSrc; - IndicatorStateProviderSRef m_indicatorStPrv; - VoiceControlStateProviderSRef m_voiceControlPrv; - }; - -} - -#endif // __CALLUI_MODEL_CALL_H__ diff --git a/src/model/CallBuilder.cpp b/src/model/CallBuilder.cpp deleted file mode 100644 index 5826135..0000000 --- a/src/model/CallBuilder.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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() - { - } - - ICallSRef CallBuilder::build() const - { - auto result = makeShared(); - FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!"); - return result; - } - -} diff --git a/src/model/CallUI.cpp b/src/model/CallUI.cpp new file mode 100644 index 0000000..11eb494 --- /dev/null +++ b/src/model/CallUI.cpp @@ -0,0 +1,315 @@ +/* + * 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 "CallUI.h" + +#include + +#include "model/ICallListener.h" +#include "model/IIncomingCall.h" +#include "model/IActiveCall.h" +#include "model/IHeldCall.h" +#include "model/IEndCall.h" +#include "model/ICallInfo.h" + +#include "CallClient.h" +#include "CallManager.h" +#include "SoundManager.h" + +#include "VoiceControlStateProvider.h" +#include "IndicatorStateProvider.h" + +#include "ConnectionStateSource.h" +#include "RssiStateSource.h" +#include "BatteryStateSource.h" +#include "VoiceControlStateSource.h" +#include "SimSlotStateSource.h" +#include "HdVoiceStateSource.h" + +#include "common.h" + +namespace callui { + + using namespace ucl; + + CallUI::CallUI(IRefCountObj &rc): + RefCountAware(&rc) + { + } + + CallUI::~CallUI() + { + } + + void CallUI::setListener(const ICallListenerWRef &listener) + { + m_listener = listener; + } + + Result CallUI::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(atoi(tmp)))); + + } else { + tmp = static_cast(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 CallUI::prepare() + { + auto callClient = CallClient::newInstance(); + if (!callClient) { + LOG_RETURN(RES_FAIL, + "Client::newInstance() failed!"); + } + + m_callManager = CallManager::newInstance(callClient, asWeak(*this)); + if (!m_callManager) { + LOG_RETURN(RES_FAIL, + "CallManager::newInstance() failed!"); + } + + m_soundManager = SoundManager::newInstance(callClient); + if (!m_soundManager) { + LOG_RETURN(RES_FAIL, + "SoundManage::newInstance() failed!"); + } + + m_voiceControlPrv = VoiceControlStateProvider::newInstance(); + if (!m_voiceControlPrv) { + LOG_RETURN(RES_FAIL, + "VoiceControlStateProvider::newInstance() failed!"); + } + + FAIL_RETURN(initInidcatorStateProvider(), + "Init Indicator State Provider failed!"); + + return RES_OK; + } + + Result CallUI::initInidcatorStateProvider() + { + m_indicatorStPrv = IndicatorStateProvider::newInstance(); + if (!m_indicatorStPrv) { + LOG_RETURN(RES_FAIL, "IndicatorStateProvider::newInstance() failed!"); + } + + auto connStateSource = ConnectionStateSource::newInstance(); + if (!connStateSource) { + LOG_RETURN(RES_FAIL, + "ConnectionStateSource::newInstance() failed!"); + } + FAIL_RETURN(m_indicatorStPrv->setStateSource( + IndicatorProperty::NW_CONNECTION, connStateSource), + "setStateSource() failed!"); + + auto rssiStSrc = RssiStateSource::newInstance(); + if (!rssiStSrc) { + LOG_RETURN(RES_FAIL, + "RssiStateSource::newInstance() failed!"); + } + FAIL_RETURN(m_indicatorStPrv->setStateSource( + IndicatorProperty::RSSI, rssiStSrc), + "setStateSource() failed!"); + + auto batteryStSrc = BatteryStateSource::newInstance(); + if (!batteryStSrc) { + LOG_RETURN(RES_FAIL, + "BatteryStateSource::newInstance() failed!"); + } + FAIL_RETURN(m_indicatorStPrv->setStateSource( + IndicatorProperty::BATTERY, batteryStSrc), + "setStateSource() failed!"); + + auto voiceControlStSrc = + VoiceControlStateSource::newInstance(m_voiceControlPrv); + if (!voiceControlStSrc) { + LOG_RETURN(RES_FAIL, + "VoiceControlStateSource::newInstance() failed!"); + } + FAIL_RETURN(m_indicatorStPrv->setStateSource( + IndicatorProperty::VOICE_CONTROL, voiceControlStSrc), + "setStateSource() failed!"); + + m_simSlotStSrc = makeShared( + m_callManager->getSimSlot(), getForwardedCallStatus()); + FAIL_RETURN(m_indicatorStPrv->setStateSource( + IndicatorProperty::SIM_SLOT, m_simSlotStSrc), + "setStateSource() failed!"); + + m_hdCallStSrc = makeShared( + getHDVoiceStatus()); + FAIL_RETURN(m_indicatorStPrv->setStateSource( + IndicatorProperty::HD_VOICE, m_hdCallStSrc), + "setStateSource() failed!"); + + return RES_OK; + } + + ICallManagerSRef CallUI::getCallManager() + { + return m_callManager; + } + + ISoundManagerSRef CallUI::getSoundManager() + { + return m_soundManager; + } + + IIndicatorStateProviderSRef CallUI::getIndicatorStateProvider() + { + return m_indicatorStPrv; + } + + ICallInfoSCRef CallUI::getCurrentCallInfo() const + { + CallMask calls = m_callManager->getAvailableCalls(); + if (!calls) { + DLOG("No available calls"); + return {}; + } else if (calls & CALL_FLAG_INCOMING) { + return m_callManager->getIncomingCall()->getInfo(); + } else if (calls & CALL_FLAG_ACTIVE) { + return m_callManager->getActiveCall()->getInfo(); + } else if (calls & CALL_FLAG_HELD) { + return m_callManager->getHeldCall()->getInfo(); + } else if (calls & CALL_FLAG_END) { + return m_callManager->getEndCall()->getInfo(); + } + return {}; + } + + bool CallUI::getHDVoiceStatus() const + { + ICallInfoSCRef info = getCurrentCallInfo(); + if (info) { + return info->isHDVoice(); + } + return false; + } + + bool CallUI::getForwardedCallStatus() const + { + ICallInfoSCRef info = getCurrentCallInfo(); + if (info) { + return info->isForwarded(); + } + return false; + } + + void CallUI::updateHdVoiceStateSource() + { + m_hdCallStSrc->updateState(getHDVoiceStatus()); + } + + void CallUI::updateSimSlotStateSource() + { + m_simSlotStSrc->updateSimSlot(m_callManager->getSimSlot(), + getForwardedCallStatus()); + } + + void CallUI::onCallEvent(CallEventType type) + { + updateSimSlotStateSource(); + updateHdVoiceStateSource(); + + if (const auto listener = m_listener.lock()) { + listener->onCallEvent(type); + } + } + + void CallUI::onError(CallManagerErr err) + { + auto 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 (const auto listener = m_listener.lock()) { + listener->onError(callErr); + } + } + +} diff --git a/src/model/CallUI.h b/src/model/CallUI.h new file mode 100644 index 0000000..1be1aa3 --- /dev/null +++ b/src/model/CallUI.h @@ -0,0 +1,78 @@ +/* + * 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_UI_H__ +#define __CALLUI_MODEL_CALL_UI_H__ + +#include "model/ICallUI.h" + +#include "ICallManagerListener.h" + +#include "types.h" + +namespace callui { + + UCL_DECLARE_REF_ALIASES(CallManager); + UCL_DECLARE_REF_ALIASES(SoundManager); + + class CallUI final : + public ucl::RefCountAware, + public ICallUI, + public ICallManagerListener { + public: + virtual ~CallUI(); + + // ICallUI + + virtual void setListener(const ICallListenerWRef &listener) override final; + virtual ucl::Result processAppControl(app_control_h appControl) override final; + virtual ISoundManagerSRef getSoundManager() override final; + virtual ICallManagerSRef getCallManager() override final; + virtual IIndicatorStateProviderSRef getIndicatorStateProvider() override final; + + // ICallManagerListener + + virtual void onCallEvent(CallEventType type) override final; + virtual void onError(CallManagerErr err) override final; + + private: + friend class CallUIBuilder; + friend class ucl::ReffedObj; + CallUI(ucl::IRefCountObj &rc); + + ucl::Result prepare(); + + ucl::Result initInidcatorStateProvider(); + + void updateHdVoiceStateSource(); + void updateSimSlotStateSource(); + ICallInfoSCRef getCurrentCallInfo() const; + bool getHDVoiceStatus() const; + bool getForwardedCallStatus() const; + + private: + CallManagerSRef m_callManager; + SoundManagerSRef m_soundManager; + ICallListenerWRef m_listener; + SimSlotStateSourceSRef m_simSlotStSrc; + HdVoiceStateSourceSRef m_hdCallStSrc; + IndicatorStateProviderSRef m_indicatorStPrv; + VoiceControlStateProviderSRef m_voiceControlPrv; + }; + +} + +#endif // __CALLUI_MODEL_CALL_UI_H__ diff --git a/src/model/CallUIBuilder.cpp b/src/model/CallUIBuilder.cpp new file mode 100644 index 0000000..5a9d5ba --- /dev/null +++ b/src/model/CallUIBuilder.cpp @@ -0,0 +1,38 @@ +/* + * 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/CallUIBuilder.h" + +#include "CallUI.h" + +#include "common.h" + +namespace callui { + + using namespace ucl; + + CallUIBuilder::CallUIBuilder() + { + } + + ICallUISRef CallUIBuilder::build() const + { + auto result = makeShared(); + FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!"); + return result; + } + +} diff --git a/src/presenters/Instance.cpp b/src/presenters/Instance.cpp index 8da8645..e77f8c4 100644 --- a/src/presenters/Instance.cpp +++ b/src/presenters/Instance.cpp @@ -22,8 +22,8 @@ #include -#include "model/CallBuilder.h" -#include "model/ICall.h" +#include "model/CallUIBuilder.h" +#include "model/ICallUI.h" #include "model/ICallManager.h" #include "presenters/MainPage.h" @@ -81,7 +81,7 @@ namespace callui { FAIL_RETURN(setupTheme(), "setupTheme() failed!"); - m_call = CallBuilder().build(); + m_call = CallUIBuilder().build(); if (!m_call) { LOG_RETURN(RES_FAIL, "m_call is NULL"); } @@ -118,7 +118,7 @@ namespace callui { if (!m_page) { auto page = MainPage::Builder(). setNaviframe(m_navi). - setCall(m_call). + setCallUI(m_call). build(WEAK_DELEGATE(Instance::onPageExitRequest, asWeak(this))); if (!page) { diff --git a/src/presenters/MainPage.cpp b/src/presenters/MainPage.cpp index 0d10949..1a491b4 100644 --- a/src/presenters/MainPage.cpp +++ b/src/presenters/MainPage.cpp @@ -19,7 +19,7 @@ #include "ucl/gui/Window.h" #include "ucl/gui/Widget.h" -#include "model/ICall.h" +#include "model/ICallUI.h" #include "model/ICallManager.h" #include "model/IIncomingCall.h" #include "model/IActiveCall.h" @@ -88,8 +88,8 @@ namespace callui { return *this; } - MainPage::Builder &MainPage::Builder::setCall( - const ICallSRef &call) + MainPage::Builder &MainPage::Builder::setCallUI( + const ICallUISRef &call) { m_call = call; return *this; @@ -128,7 +128,7 @@ namespace callui { MainPage::MainPage(IRefCountObj &rc, const NaviframeSRef &navi, const ExitRequestHandler handler, - const ICallSRef &call) : + const ICallUISRef &call) : Page(rc, navi, handler), m_call(call), m_mode(CallMode::UNDEFINED),