From: Igor Olshevskyi Date: Thu, 6 Apr 2017 10:53:46 +0000 (+0300) Subject: TizenRefApp-8340 [Call UI] Add IBaseCallInfo class and replace checking DialingMode... X-Git-Tag: submit/tizen/20170630.111746~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5fc90e096dac17f31c86a049f3d85391b1cc926d;p=profile%2Fwearable%2Fapps%2Fnative%2Fcall-ui.git TizenRefApp-8340 [Call UI] Add IBaseCallInfo class and replace checking DialingMode from CallInfo into ActiveCall Change-Id: Id7b58763f117606399099be3509462e8f510cf2c --- diff --git a/inc/model/IActiveCall.h b/inc/model/IActiveCall.h index c78fc60..2d58a09 100644 --- a/inc/model/IActiveCall.h +++ b/inc/model/IActiveCall.h @@ -24,9 +24,10 @@ namespace callui { class IActiveCall : public ucl::Polymorphic { public: virtual ICallInfoSCRef getInfo() const = 0; + virtual bool isDialingMode() const = 0; virtual ucl::Result hold() = 0; virtual ucl::Result end() = 0; - virtual ucl::Result split(const IConferenceCallInfoSRef &confCallInfo) = 0; + virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) = 0; }; } diff --git a/inc/model/IBaseCallInfo.h b/inc/model/IBaseCallInfo.h new file mode 100644 index 0000000..3d1dd6a --- /dev/null +++ b/inc/model/IBaseCallInfo.h @@ -0,0 +1,33 @@ +/* + * 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_BASE_CALL_INFO_H__ +#define __CALLUI_MODEL_I_BASE_CALL_INFO_H__ + +#include "types.h" + +namespace callui { + + class IBaseCallInfo : public ucl::Polymorphic { + public: + virtual unsigned int getCallId() const = 0; + virtual const std::string &getPhoneNumber() const = 0; + virtual IContactInfoSCRef getContactInfo() const = 0; + }; + +} + +#endif // __CALLUI_MODEL_I_BASE_CALL_INFO_H__ diff --git a/inc/model/ICallInfo.h b/inc/model/ICallInfo.h index c94db98..4a30b11 100644 --- a/inc/model/ICallInfo.h +++ b/inc/model/ICallInfo.h @@ -17,20 +17,18 @@ #ifndef __CALLUI_MODEL_I_CALL_INFO_H__ #define __CALLUI_MODEL_I_CALL_INFO_H__ +#include "IBaseCallInfo.h" + #include "types.h" namespace callui { - class ICallInfo : public ucl::Polymorphic { + class ICallInfo : public IBaseCallInfo { public: - virtual unsigned int getCallId() const = 0; - virtual const std::string &getPhoneNumber() const = 0; - virtual IContactInfoSCRef getContactInfo() const = 0; virtual long getStartTime() const = 0; virtual bool isEmergency() const = 0; - virtual bool isDialing() const = 0; virtual int getConferenceMemberCount() const = 0; - virtual const ConfMemberCallList &getConferenceMemberList() const = 0; + virtual const ConfMemberList &getConferenceMemberList() const = 0; }; } diff --git a/inc/model/IConferenceCallInfo.h b/inc/model/IConferenceCallInfo.h index 96873eb..c2c24b9 100644 --- a/inc/model/IConferenceCallInfo.h +++ b/inc/model/IConferenceCallInfo.h @@ -17,15 +17,13 @@ #ifndef __CALLUI_MODEL_I_CONFERENCE_CALL_INFO_H__ #define __CALLUI_MODEL_I_CONFERENCE_CALL_INFO_H__ +#include "IBaseCallInfo.h" + #include "types.h" namespace callui { - class IConferenceCallInfo : public ucl::Polymorphic { - public: - virtual unsigned int getCallId() const = 0; - virtual const std::string &getPhoneNumber() const = 0; - virtual IContactInfoSRef getContactInfo() const = 0; + class IConferenceCallInfo : public IBaseCallInfo { }; } diff --git a/inc/model/IHeldCall.h b/inc/model/IHeldCall.h index 3b46357..030ae5d 100644 --- a/inc/model/IHeldCall.h +++ b/inc/model/IHeldCall.h @@ -28,7 +28,7 @@ namespace callui { virtual ucl::Result joinWithActive() = 0; virtual ucl::Result swapWithActive() = 0; virtual ucl::Result end() = 0; - virtual ucl::Result split(const IConferenceCallInfoSRef &confCallInfo) = 0; + virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) = 0; }; } diff --git a/inc/model/types.h b/inc/model/types.h index 5fb856a..a5a1ff2 100644 --- a/inc/model/types.h +++ b/inc/model/types.h @@ -29,13 +29,6 @@ namespace callui { DEFAULT }; - enum class CallReleaseType { - BY_CALL_HANDLE, - ALL, - ALL_HOLD, - ALL_ACTIVE - }; - enum class CallAnswerType { NORMAL, HOLD_ACTIVE_AND_ACCEPT, @@ -118,7 +111,7 @@ namespace callui { using AudioStateHandler = ucl::Delegate; using MuteStateHandler = ucl::Delegate; - using ConfMemberCallList = std::vector; + using ConfMemberList = std::vector; using RejectMsgList = std::vector; } diff --git a/src/common.h b/src/common.h index 3b25582..b2d0927 100644 --- a/src/common.h +++ b/src/common.h @@ -31,6 +31,9 @@ #undef UCL_LOG_TAG #define UCL_LOG_TAG "CALLUI" -#define TEL_NUMBER_MAX_SIZE 82 +namespace callui { + + constexpr auto TEL_NUMBER_MAX_SIZE = 82; +} #endif // __CALLUI_COMMON_H__ diff --git a/src/model/ActiveCall.cpp b/src/model/ActiveCall.cpp index 6c09ebc..e238abd 100644 --- a/src/model/ActiveCall.cpp +++ b/src/model/ActiveCall.cpp @@ -16,7 +16,8 @@ #include "ActiveCall.h" -#include "CallClient.h" +#include + #include "CallManager.h" #include "CallClient.h" #include "CallInfo.h" @@ -29,7 +30,8 @@ namespace callui { ActiveCall::ActiveCall(CallManager &cm, cm_call_data_h callData): BaseCall(callData), - m_cm(cm) + m_cm(cm), + m_isDialing(false) { } @@ -54,6 +56,13 @@ namespace callui { 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() failed!"); + m_isDialing = (callState == CM_CALL_STATE_DIALING); + return RES_OK; } @@ -62,9 +71,14 @@ namespace callui { return m_callInfo; } + bool ActiveCall::isDialingMode() const + { + return m_isDialing; + } + Result ActiveCall::hold() { - return convertCallManagerResult(cm_hold_call(*m_cm.getCallClient())); + return convertCMResult(cm_hold_call(*m_cm.getCallClient())); } Result ActiveCall::end() @@ -72,7 +86,7 @@ namespace callui { return m_cm.endCall(0, CallReleaseType::ALL_ACTIVE); } - Result ActiveCall::split(const IConferenceCallInfoSRef &confCallInfo) + Result ActiveCall::split(const IConferenceCallInfoSCRef &confCallInfo) { return m_cm.splitCalls(m_callInfo, confCallInfo); } diff --git a/src/model/ActiveCall.h b/src/model/ActiveCall.h index 8d8e0cc..7a60d09 100644 --- a/src/model/ActiveCall.h +++ b/src/model/ActiveCall.h @@ -36,9 +36,10 @@ namespace callui { // IActiveCall virtual ICallInfoSCRef getInfo() const override final; + virtual bool isDialingMode() const override final; virtual ucl::Result hold() override final; virtual ucl::Result end() override final; - virtual ucl::Result split(const IConferenceCallInfoSRef &confCallInfo) override final; + virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) override final; private: friend class ucl::RefCountObj; @@ -49,6 +50,7 @@ namespace callui { private: CallManager &m_cm; CallInfoSRef m_callInfo; + bool m_isDialing; }; } diff --git a/src/model/Call.cpp b/src/model/Call.cpp index b79724b..0c4b716 100644 --- a/src/model/Call.cpp +++ b/src/model/Call.cpp @@ -41,7 +41,7 @@ namespace callui { return result; } - ucl::Result Call::prepare() + Result Call::prepare() { CallClientSRef callClient = CallClient::newInstance(); if (!callClient) { diff --git a/src/model/CallClient.cpp b/src/model/CallClient.cpp index a86cacf..34b4b0d 100644 --- a/src/model/CallClient.cpp +++ b/src/model/CallClient.cpp @@ -44,7 +44,7 @@ namespace callui { ucl::Result CallClient::prepare() { cm_client_h client; - FAIL_RETURN_VALUE(convertCallManagerResult(cm_init(&client)), {}, "cm_init() failed!"); + FAIL_RETURN_VALUE(convertCMResult(cm_init(&client)), {}, "cm_init() failed!"); m_client = client; return RES_OK; diff --git a/src/model/CallDialer.cpp b/src/model/CallDialer.cpp index eb8bc69..4bfef71 100644 --- a/src/model/CallDialer.cpp +++ b/src/model/CallDialer.cpp @@ -44,12 +44,12 @@ namespace callui { void CallDialer::DialStatusChangedCb(cm_dial_status_e status) { - m_event.invoke(convertCallManagerDialStatus(status)); + m_event.invoke(convertCMDialStatus(status)); } Result CallDialer::prepare() { - return convertCallManagerResult( + return convertCMResult( cm_set_dial_status_cb(*(m_cm.getCallClient()), CALLBACK_B(CallDialer::DialStatusChangedCb), this)); } @@ -59,9 +59,9 @@ namespace callui { char buff[TEL_NUMBER_MAX_SIZE] = { 0 }; snprintf(buff, sizeof(buff), "%s", number.c_str()); - return convertCallManagerResult( + return convertCMResult( cm_dial_call(*(m_cm.getCallClient()), - buff, CM_CALL_TYPE_VOICE, convertCallAppSimSlot(simSlot))); + buff, CM_CALL_TYPE_VOICE, convertCUISimSlot(simSlot))); } void CallDialer::addDialStatusHandler(DialStatusHandler handler) diff --git a/src/model/CallInfo.cpp b/src/model/CallInfo.cpp index ac30763..4659a8d 100644 --- a/src/model/CallInfo.cpp +++ b/src/model/CallInfo.cpp @@ -34,7 +34,6 @@ namespace callui { m_callId(-1), m_startTime(0), m_isEmergency(false), - m_isDialing(false), m_confMemberCount(0) { } @@ -60,31 +59,26 @@ namespace callui { Result CallInfo::prepare(CallClient &client, cm_call_data_h callData) { - Result res = convertCallManagerResult(cm_call_data_get_call_id(callData, &m_callId)); + Result res = convertCMResult(cm_call_data_get_call_id(callData, &m_callId)); FAIL_RETURN(res, "cm_call_data_get_call_id() failed!"); char *number = nullptr; - res = convertCallManagerResult(cm_call_data_get_call_number(callData, &number)); + res = convertCMResult(cm_call_data_get_call_number(callData, &number)); FAIL_RETURN(res, "cm_call_data_get_call_number() failed!"); m_phoneNum = nz(number); // XXX: According to documentation it must be free, but it leads to crash // free(number); gboolean isEmergency; - res = convertCallManagerResult(cm_call_data_is_emergency_call(callData, &isEmergency)); + res = convertCMResult(cm_call_data_is_emergency_call(callData, &isEmergency)); FAIL_RETURN(res, "cm_call_data_is_emergency_call() failed!"); m_isEmergency = isEmergency; - cm_call_state_e callState = CM_CALL_STATE_IDLE; - res = convertCallManagerResult(cm_call_data_get_call_state(callData, &callState)); - FAIL_RETURN(res, "cm_call_data_get_call_state() failed!"); - m_isDialing = (callState == CM_CALL_STATE_DIALING); - - res = convertCallManagerResult(cm_call_data_get_start_time(callData, &m_startTime)); + res = convertCMResult(cm_call_data_get_start_time(callData, &m_startTime)); FAIL_RETURN(res, "cm_call_data_get_start_time() failed!"); int personId = -1; - res = convertCallManagerResult(cm_call_data_get_person_id(callData, &personId)); + res = convertCMResult(cm_call_data_get_person_id(callData, &personId)); FAIL_RETURN(res, "cm_call_data_get_person_id() failed!"); if (personId >= 0) { @@ -94,7 +88,7 @@ namespace callui { } } - res = convertCallManagerResult(cm_call_data_get_call_member_count(callData, &m_confMemberCount)); + res = convertCMResult(cm_call_data_get_call_member_count(callData, &m_confMemberCount)); FAIL_RETURN(res, "cm_call_data_get_call_member_count() failed!"); if (m_confMemberCount > 1) { @@ -110,7 +104,7 @@ namespace callui { // XXX: must be initialized with nullptr. If not an there is no conference calls // cm_get_conference_callList return CM_ERROR_NONE and pointer will be not changed. GSList *callList = nullptr; - Result res = convertCallManagerResult(cm_get_conference_call_list(client, &callList)); + Result res = convertCMResult(cm_get_conference_call_list(client, &callList)); FAIL_RETURN(res, "cm_get_conference_call_list() failed!"); if (callList) { @@ -160,17 +154,12 @@ namespace callui { return m_isEmergency; } - bool CallInfo::isDialing() const - { - return m_isDialing; - } - int CallInfo::getConferenceMemberCount() const { return m_confMemberCount; } - const ConfMemberCallList &CallInfo::getConferenceMemberList() const + const ConfMemberList &CallInfo::getConferenceMemberList() const { return m_confMemberList; } diff --git a/src/model/CallInfo.h b/src/model/CallInfo.h index b55b122..72b0c38 100644 --- a/src/model/CallInfo.h +++ b/src/model/CallInfo.h @@ -37,9 +37,8 @@ namespace callui { virtual IContactInfoSCRef getContactInfo() const override final; virtual long getStartTime() const override final; virtual bool isEmergency() const override final; - virtual bool isDialing() const override final; virtual int getConferenceMemberCount() const override final; - virtual const ConfMemberCallList &getConferenceMemberList() const override final; + virtual const ConfMemberList &getConferenceMemberList() const override final; private: friend class ucl::RefCountObj; @@ -54,9 +53,8 @@ namespace callui { ContactInfoSRef m_contactInfo; long m_startTime; bool m_isEmergency; - bool m_isDialing; int m_confMemberCount; - ConfMemberCallList m_confMemberList; + ConfMemberList m_confMemberList; }; } diff --git a/src/model/CallManager.cpp b/src/model/CallManager.cpp index 810cf8a..5c4f823 100644 --- a/src/model/CallManager.cpp +++ b/src/model/CallManager.cpp @@ -58,7 +58,7 @@ namespace callui { FAIL_RETURN(initCalls(), "initCalls() failed!"); - FAIL_RETURN(convertCallManagerResult( + FAIL_RETURN(convertCMResult( cm_set_call_event_cb(*m_callClient, CALLBACK_B(CallManager::callEventCb), this)), "cm_set_call_event_cb() failed!"); @@ -71,7 +71,7 @@ namespace callui { cm_call_data_h active = nullptr; cm_call_data_h held = nullptr; - FAIL_RETURN(convertCallManagerResult( + FAIL_RETURN(convertCMResult( cm_get_all_calldata(*m_callClient, &incom, &active, &held)), "cm_get_all_calldata() failed!"); @@ -180,11 +180,11 @@ namespace callui { Result CallManager::endCall(unsigned int callId, CallReleaseType type) { - return convertCallManagerResult( - cm_end_call(*m_callClient, callId, convertCallAppReleaseType(type))); + return convertCMResult( + cm_end_call(*m_callClient, callId, convertCUICallReleaseType(type))); } - Result CallManager::splitCalls(CallInfoSRef callInfo, const IConferenceCallInfoSRef &confCallInfo) + Result CallManager::splitCalls(CallInfoSRef callInfo, const IConferenceCallInfoSCRef &confCallInfo) { if (callInfo->getConferenceMemberCount() <= 1) { LOG_RETURN(RES_FAIL, "Not conference call"); @@ -214,7 +214,7 @@ namespace callui { Result CallManager::processEndCallEvent(cm_call_event_data_h callEventData, SimSlot simSlot) { unsigned int callId = 0; - FAIL_RETURN(convertCallManagerResult( + FAIL_RETURN(convertCMResult( cm_call_event_data_get_call_id(callEventData, &callId)), "cm_call_event_data_get_call_id() failed!"); @@ -246,19 +246,19 @@ namespace callui { cm_call_data_h cmActive = nullptr; cm_call_data_h cmHeld = nullptr; - FAIL_RETURN(convertCallManagerResult( + FAIL_RETURN(convertCMResult( cm_call_event_data_get_call_id(callEventData, &callId)), "cm_call_event_data_get_call_id() failed!"); - FAIL_RETURN(convertCallManagerResult( + FAIL_RETURN(convertCMResult( cm_call_event_data_get_incom_call(callEventData, &cmIncom)), "cm_call_event_data_get_incom_call() failed!"); - FAIL_RETURN(convertCallManagerResult( + FAIL_RETURN(convertCMResult( cm_call_event_data_get_active_call(callEventData, &cmActive)), "cm_call_event_data_get_active_call() failed!"); - FAIL_RETURN(convertCallManagerResult( + FAIL_RETURN(convertCMResult( cm_call_event_data_get_held_call(callEventData, &cmHeld)), "cm_call_event_data_get_held_call() failed!"); @@ -281,16 +281,16 @@ namespace callui { } CallEventType type; - FAIL_RETURN_VOID(convertCallManagerEventType(callEvent, &type), + FAIL_RETURN_VOID(convertCMEventType(callEvent, &type), "convertCallManagerEventType() failed!"); DLOG("Call event changed on [%d]", type); cm_multi_sim_slot_type_e cmSimSlot; - FAIL_RETURN_VOID(convertCallManagerResult( + FAIL_RETURN_VOID(convertCMResult( cm_call_event_data_get_sim_slot(callEventData, &cmSimSlot)), "cm_call_event_data_get_sim_slot() failed!"); - SimSlot simSlot = convertCallManagerSimSlot(cmSimSlot); + SimSlot simSlot = convertCMSimSlot(cmSimSlot); m_endCall.reset(); diff --git a/src/model/CallManager.h b/src/model/CallManager.h index 56c2199..4e2770b 100644 --- a/src/model/CallManager.h +++ b/src/model/CallManager.h @@ -35,7 +35,7 @@ namespace callui { CallClientSRef getCallClient(); ucl::Result endCall(unsigned int callId, CallReleaseType type); ucl::Result splitCalls(CallInfoSRef callInfo, - const IConferenceCallInfoSRef &confCallInfo); + const IConferenceCallInfoSCRef &confCallInfo); RejectMsgProviderSRef getRejectMsgProvider(); // ICallManager diff --git a/src/model/ConferenceCallInfo.cpp b/src/model/ConferenceCallInfo.cpp index f4119e3..2f026e2 100644 --- a/src/model/ConferenceCallInfo.cpp +++ b/src/model/ConferenceCallInfo.cpp @@ -48,19 +48,19 @@ namespace callui { Result ConferenceCallInfo::prepare(cm_conf_call_data_t *confCallData) { - Result res = convertCallManagerResult(cm_conf_call_data_get_call_id(confCallData, &m_callId)); - FAIL_RETURN_VALUE(res, res, "cm_conf_call_data_get_call_id() failed!"); + Result res = convertCMResult(cm_conf_call_data_get_call_id(confCallData, &m_callId)); + FAIL_RETURN(res, "cm_conf_call_data_get_call_id() failed!"); char *number = nullptr; - res = convertCallManagerResult(cm_conf_call_data_get_call_number(confCallData, &number)); - FAIL_RETURN_VALUE(res, res, "cm_conf_call_data_get_call_number() failed!"); + res = convertCMResult(cm_conf_call_data_get_call_number(confCallData, &number)); + FAIL_RETURN(res, "cm_conf_call_data_get_call_number() failed!"); m_phoneNum = nz(number); // XXX: According to documentation it must be free, but it leads to crash // free(number); int personId = -1; - res = convertCallManagerResult(cm_conf_call_data_get_person_id(confCallData, &personId)); - FAIL_RETURN_VALUE(res, res, "cm_conf_call_data_get_person_id() failed!"); + res = convertCMResult(cm_conf_call_data_get_person_id(confCallData, &personId)); + FAIL_RETURN(res, "cm_conf_call_data_get_person_id() failed!"); if (personId >= 0) { m_contactInfo = ContactInfo::newInstance(personId); @@ -81,7 +81,7 @@ namespace callui { return m_phoneNum; } - IContactInfoSRef ConferenceCallInfo::getContactInfo() const + IContactInfoSCRef ConferenceCallInfo::getContactInfo() const { return m_contactInfo; } diff --git a/src/model/ConferenceCallInfo.h b/src/model/ConferenceCallInfo.h index 8335d75..fe9ab9a 100644 --- a/src/model/ConferenceCallInfo.h +++ b/src/model/ConferenceCallInfo.h @@ -34,7 +34,7 @@ namespace callui { virtual unsigned int getCallId() const override final; virtual const std::string &getPhoneNumber() const override final; - virtual IContactInfoSRef getContactInfo() const override final; + virtual IContactInfoSCRef getContactInfo() const override final; private: friend class ucl::RefCountObj; diff --git a/src/model/HeldCall.cpp b/src/model/HeldCall.cpp index 098f5ba..ff7766c 100644 --- a/src/model/HeldCall.cpp +++ b/src/model/HeldCall.cpp @@ -64,17 +64,17 @@ namespace callui { Result HeldCall::unhold() { - return convertCallManagerResult(cm_unhold_call(*m_cm.getCallClient())); + return convertCMResult(cm_unhold_call(*m_cm.getCallClient())); } Result HeldCall::joinWithActive() { - return convertCallManagerResult(cm_join_call(*m_cm.getCallClient())); + return convertCMResult(cm_join_call(*m_cm.getCallClient())); } Result HeldCall::swapWithActive() { - return convertCallManagerResult(cm_swap_call(*m_cm.getCallClient())); + return convertCMResult(cm_swap_call(*m_cm.getCallClient())); } Result HeldCall::end() @@ -82,7 +82,7 @@ namespace callui { return m_cm.endCall(0, CallReleaseType::ALL_HOLD); } - Result HeldCall::split(const IConferenceCallInfoSRef &confCallInfo) + Result HeldCall::split(const IConferenceCallInfoSCRef &confCallInfo) { return m_cm.splitCalls(m_callInfo, confCallInfo); } diff --git a/src/model/HeldCall.h b/src/model/HeldCall.h index c584c55..80f7d01 100644 --- a/src/model/HeldCall.h +++ b/src/model/HeldCall.h @@ -40,7 +40,7 @@ namespace callui { virtual ucl::Result joinWithActive() override final; virtual ucl::Result swapWithActive() override final; virtual ucl::Result end() override final; - virtual ucl::Result split(const IConferenceCallInfoSRef &confCallInfo) override final; + virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) override final; private: friend class ucl::RefCountObj; diff --git a/src/model/IncomingCall.cpp b/src/model/IncomingCall.cpp index 0c05ccd..d45c105 100644 --- a/src/model/IncomingCall.cpp +++ b/src/model/IncomingCall.cpp @@ -73,12 +73,12 @@ namespace callui { Result IncomingCall::answer(CallAnswerType type) { - return convertCallManagerResult(cm_answer_call(*m_cm.getCallClient(), convertCallAppAnswerType(type))); + return convertCMResult(cm_answer_call(*m_cm.getCallClient(), convertCUICallAnswerType(type))); } Result IncomingCall::reject() { - return convertCallManagerResult(cm_reject_call(*m_cm.getCallClient())); + return convertCMResult(cm_reject_call(*m_cm.getCallClient())); } Result IncomingCall::rejectWithMessage(IRejectMsgSRef message) @@ -94,7 +94,7 @@ namespace callui { Result IncomingCall::stopAlert() { - return convertCallManagerResult(cm_stop_alert(*m_cm.getCallClient())); + return convertCMResult(cm_stop_alert(*m_cm.getCallClient())); } } diff --git a/src/model/MsgClient.cpp b/src/model/MsgClient.cpp index 2a7b0fc..e0cad27 100644 --- a/src/model/MsgClient.cpp +++ b/src/model/MsgClient.cpp @@ -26,13 +26,15 @@ namespace callui { using namespace ucl; MsgClient::MsgClient(): - m_handle(nullptr) + m_handle() { } MsgClient::~MsgClient() { - msg_close_msg_handle(&m_handle); + if (m_handle) { + msg_close_msg_handle(&m_handle); + } } MsgClientSRef MsgClient::newInstance() @@ -44,10 +46,12 @@ namespace callui { Result MsgClient::prepare() { - msg_error_t err = msg_open_msg_handle(&m_handle); + msg_handle_t handle; + msg_error_t err = msg_open_msg_handle(&handle); if (err != MSG_SUCCESS) { LOG_RETURN(RES_FAIL, "msg_open_msg_handle() failed! res[%d]", err); } + m_handle = handle; err = msg_reg_sent_status_callback(m_handle, [](msg_handle_t msgHandle, msg_struct_t status, void *data) { diff --git a/src/model/SoundManager.cpp b/src/model/SoundManager.cpp index edac344..bcd5d95 100644 --- a/src/model/SoundManager.cpp +++ b/src/model/SoundManager.cpp @@ -49,7 +49,7 @@ namespace callui { return; } - m_audioStateEvent.invoke(convertCallManagerAudioState(state)); + m_audioStateEvent.invoke(convertCMAudioState(state)); } void SoundManager::muteStateChangedCb(cm_mute_status_e status) @@ -59,11 +59,11 @@ namespace callui { Result SoundManager::prepare() { - Result res = convertCallManagerResult(cm_set_audio_state_changed_cb(*m_client, CALLBACK_B(SoundManager::audioStateChangedCb), this)); - FAIL_RETURN_VALUE(res, res, "cm_set_audio_state_changed_cb() failed!"); + Result res = convertCMResult(cm_set_audio_state_changed_cb(*m_client, CALLBACK_B(SoundManager::audioStateChangedCb), this)); + FAIL_RETURN(res, "cm_set_audio_state_changed_cb() failed!"); - res = convertCallManagerResult(cm_set_mute_status_cb(*m_client, CALLBACK_B(SoundManager::muteStateChangedCb), this)); - FAIL_RETURN_VALUE(res, res, "__callui_mute_state_changed_cb() failed!"); + res = convertCMResult(cm_set_mute_status_cb(*m_client, CALLBACK_B(SoundManager::muteStateChangedCb), this)); + FAIL_RETURN(res, "__callui_mute_state_changed_cb() failed!"); return res; } @@ -71,39 +71,39 @@ namespace callui { Result SoundManager::setSpeakerState(bool isEnable) { if (isEnable) { - return convertCallManagerResult(cm_speaker_on(*m_client)); + return convertCMResult(cm_speaker_on(*m_client)); } else { - return convertCallManagerResult(cm_speaker_off(*m_client)); + return convertCMResult(cm_speaker_off(*m_client)); } } Result SoundManager::setBluetoothState(bool isEnable) { if (isEnable) { - return convertCallManagerResult(cm_bluetooth_on(*m_client)); + return convertCMResult(cm_bluetooth_on(*m_client)); } else { - return convertCallManagerResult(cm_bluetooth_off(*m_client)); + return convertCMResult(cm_bluetooth_off(*m_client)); } } AudioStateType SoundManager::getAudioState() const { cm_audio_state_type_e state = CM_AUDIO_STATE_NONE_E; - Result res = convertCallManagerResult(cm_get_audio_state(*m_client, &state)); + Result res = convertCMResult(cm_get_audio_state(*m_client, &state)); FAIL_RETURN_VALUE(res, AudioStateType::NONE, "cm_get_audio_state() failed!"); - return convertCallManagerAudioState(state); + return convertCMAudioState(state); } Result SoundManager::setMuteState(bool isEnable) { - return convertCallManagerResult(cm_set_mute_state(*m_client, isEnable)); + return convertCMResult(cm_set_mute_state(*m_client, isEnable)); } bool SoundManager::getMuteState() const { cm_mute_status_e status = CM_MUTE_STATUS_MAX; - Result res = convertCallManagerResult(cm_get_mute_status(*m_client, &status)); + Result res = convertCMResult(cm_get_mute_status(*m_client, &status)); FAIL_RETURN_VALUE(res, false, "cm_get_mute_status() failed!"); return (status == CM_MUTE_STATUS_ON); @@ -111,12 +111,12 @@ namespace callui { Result SoundManager::startDtmf(const unsigned char dtmfDigit) { - return convertCallManagerResult(cm_start_dtmf(*m_client, dtmfDigit)); + return convertCMResult(cm_start_dtmf(*m_client, dtmfDigit)); } Result SoundManager::stopDtmf() { - return convertCallManagerResult(cm_stop_dtmf(*m_client)); + return convertCMResult(cm_stop_dtmf(*m_client)); } void SoundManager::addAudioStateChangeHandler(AudioStateHandler handler) diff --git a/src/model/helpers.h b/src/model/helpers.h index 99b3df2..d1014e2 100644 --- a/src/model/helpers.h +++ b/src/model/helpers.h @@ -20,25 +20,25 @@ #include #include -#include "model/types.h" +#include "implTypes.h" namespace callui { - ucl::Result convertCallManagerResult(int cmRes); + ucl::Result convertCMResult(int cmRes); - AudioStateType convertCallManagerAudioState(cm_audio_state_type_e state); + AudioStateType convertCMAudioState(cm_audio_state_type_e state); - DialStatus convertCallManagerDialStatus(cm_dial_status_e status); + DialStatus convertCMDialStatus(cm_dial_status_e status); - cm_multi_sim_slot_type_e convertCallAppSimSlot(SimSlot slot); + cm_multi_sim_slot_type_e convertCUISimSlot(SimSlot slot); - SimSlot convertCallManagerSimSlot(cm_multi_sim_slot_type_e slot); + SimSlot convertCMSimSlot(cm_multi_sim_slot_type_e slot); - cm_call_release_type_e convertCallAppReleaseType(CallReleaseType type); + cm_call_release_type_e convertCUICallReleaseType(CallReleaseType type); - ucl::Result convertCallManagerEventType(cm_call_event_e cmEvent, CallEventType *appEvent); + ucl::Result convertCMEventType(cm_call_event_e cmEvent, CallEventType *appEvent); - cm_call_answer_type_e convertCallAppAnswerType(CallAnswerType type); + cm_call_answer_type_e convertCUICallAnswerType(CallAnswerType type); template constexpr auto convertEnumValueToInt(TYPE e) -> typename std::underlying_type::type diff --git a/src/model/helpers.hpp b/src/model/helpers.hpp index a2f0524..d645901 100644 --- a/src/model/helpers.hpp +++ b/src/model/helpers.hpp @@ -18,7 +18,7 @@ namespace callui { - inline ucl::Result convertCallManagerResult(int cmRes) + inline ucl::Result convertCMResult(int cmRes) { switch (cmRes) { case CM_ERROR_NONE: return ucl::RES_OK; @@ -34,7 +34,7 @@ namespace callui { } } - inline AudioStateType convertCallManagerAudioState(cm_audio_state_type_e state) + inline AudioStateType convertCMAudioState(cm_audio_state_type_e state) { switch (state) { case CM_AUDIO_STATE_NONE_E: return AudioStateType::NONE; @@ -47,7 +47,7 @@ namespace callui { } } - inline DialStatus convertCallManagerDialStatus(cm_dial_status_e status) + inline DialStatus convertCMDialStatus(cm_dial_status_e status) { switch (status) { case CM_DIAL_SUCCESS: return DialStatus::SUCCESS; @@ -61,7 +61,7 @@ namespace callui { } } - inline cm_multi_sim_slot_type_e convertCallAppSimSlot(SimSlot slot) + inline cm_multi_sim_slot_type_e convertCUISimSlot(SimSlot slot) { switch (slot) { case SimSlot::FIRST: return CM_MULTI_SIM_SLOT_1; @@ -71,7 +71,7 @@ namespace callui { } } - inline SimSlot convertCallManagerSimSlot(cm_multi_sim_slot_type_e slot) + inline SimSlot convertCMSimSlot(cm_multi_sim_slot_type_e slot) { switch (slot) { case CM_MULTI_SIM_SLOT_1: return SimSlot::FIRST; @@ -81,7 +81,7 @@ namespace callui { } } - inline cm_call_release_type_e convertCallAppReleaseType(CallReleaseType type) + inline cm_call_release_type_e convertCUICallReleaseType(CallReleaseType type) { switch (type) { case CallReleaseType::BY_CALL_HANDLE: return CM_CALL_RELEASE_TYPE_BY_CALL_HANDLE; @@ -93,7 +93,7 @@ namespace callui { } } - inline ucl::Result convertCallManagerEventType(cm_call_event_e cmEvent, CallEventType *appEvent) + inline ucl::Result convertCMEventType(cm_call_event_e cmEvent, CallEventType *appEvent) { switch (cmEvent) { case CM_CALL_EVENT_IDLE: @@ -138,7 +138,7 @@ namespace callui { return ucl::RES_OK; } - inline cm_call_answer_type_e convertCallAppAnswerType(CallAnswerType type) + inline cm_call_answer_type_e convertCUICallAnswerType(CallAnswerType type) { switch (type) { case CallAnswerType::NORMAL: return CALL_ANSWER_TYPE_NORMAL; diff --git a/src/model/implTypes.h b/src/model/implTypes.h index 27edbe7..4db1188 100644 --- a/src/model/implTypes.h +++ b/src/model/implTypes.h @@ -22,6 +22,13 @@ namespace callui { + enum class CallReleaseType { + BY_CALL_HANDLE, + ALL, + ALL_HOLD, + ALL_ACTIVE + }; + UCL_DECLARE_REF_ALIASES(CallClient); UCL_DECLARE_REF_ALIASES(SoundManager);