From fd3c4b8b15142e86ca2dce99bae0dcc53ddfbe52 Mon Sep 17 00:00:00 2001 From: Robert Borzecki Date: Wed, 7 Aug 2019 07:16:31 +0200 Subject: [PATCH] Added routing in incoming call. --- .../application-call/ApplicationCall.cpp | 6 +++++- .../application-call/windows/CallWindow.cpp | 18 +++++++++++++----- .../application-call/windows/CallWindow.hpp | 4 +++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/module-apps/application-call/ApplicationCall.cpp b/module-apps/application-call/ApplicationCall.cpp index 7c57a20ac..05a891554 100644 --- a/module-apps/application-call/ApplicationCall.cpp +++ b/module-apps/application-call/ApplicationCall.cpp @@ -75,7 +75,11 @@ sys::Message_t ApplicationCall::DataReceivedHandler(sys::DataMessage* msgl) { } else if( msg->type == CellularNotificationMessage::Type::IncomingCall ) { LOG_INFO("---------------------------------IncomingCall"); + if( callWindow->getState() == gui::CallWindow::State::INCOMING_CALL ) { + LOG_INFO("ignoring call incoming"); + } AudioServiceAPI::RoutingStart(this); + AudioServiceAPI::RoutingSpeakerPhone(this,true); runCallTimer(); std::unique_ptr data = std::make_unique(msg->data); //send to itself message to switch (run) call application @@ -83,7 +87,7 @@ sys::Message_t ApplicationCall::DataReceivedHandler(sys::DataMessage* msgl) { switchWindow( "CallWindow",0, std::move(data) ); } else { - callWindow->setState( gui::CallWindow::State::INCOMMING_CALL ); + callWindow->setState( gui::CallWindow::State::INCOMING_CALL ); sapm::ApplicationManager::messageSwitchApplication( this, "ApplicationCall", "CallWindow", std::move(data) ); } } diff --git a/module-apps/application-call/windows/CallWindow.cpp b/module-apps/application-call/windows/CallWindow.cpp index b04f4e8f0..5078c61aa 100644 --- a/module-apps/application-call/windows/CallWindow.cpp +++ b/module-apps/application-call/windows/CallWindow.cpp @@ -162,6 +162,10 @@ void CallWindow::setState( State state ) { setVisibleState(); } +const CallWindow::State& CallWindow::getState() { + return state; +} + void CallWindow::setVisibleState() { rects[static_cast(FocusRects::Speaker)]->setVisible(false); @@ -171,7 +175,7 @@ void CallWindow::setVisibleState() { //show state of the window switch( state ) { - case State::INCOMMING_CALL: { + case State::INCOMING_CALL: { titleLabel->setText("INCOMMING_CALL"); bottomBar->setActive(gui::BottomBar::Side::LEFT, true ); bottomBar->setActive(gui::BottomBar::Side::CENTER, true ); @@ -221,6 +225,10 @@ void CallWindow::setVisibleState() { }; } +void CallWindow::setCallNumber( std::string ) { + +} + void CallWindow::updateDuration( uint32_t duration ) { uint32_t seconds = 0; uint32_t minutes = 0; @@ -252,7 +260,7 @@ bool CallWindow::handleSwitchData( SwitchData* data ) { app::CallSwitchData* callData = reinterpret_cast(data); if( callData->getType() == app::CallSwitchData::Type::INCOMMING_CALL ) { app::IncommingCallData* incData = reinterpret_cast( data ); - state = State::INCOMMING_CALL; + state = State::INCOMING_CALL; numberLabel->setText( incData->getPhoneNumber()); } setVisibleState(); @@ -268,7 +276,7 @@ void CallWindow::onBeforeShow( ShowMode mode, uint32_t command, SwitchData* data } bool CallWindow::handleLeftButton() { - if( state == State::INCOMMING_CALL ) { + if( state == State::INCOMING_CALL ) { auto ret = CellularServiceAPI::AnswerIncomingCall(application); LOG_INFO("AnswerIncomingCall: %s",(ret?"OK":"FAIL")); @@ -286,7 +294,7 @@ bool CallWindow::handleLeftButton() { return false; } bool CallWindow::handleCenterButton() { - if( state == State::INCOMMING_CALL ) { + if( state == State::INCOMING_CALL ) { auto ret = CellularServiceAPI::HangupCall(application); LOG_INFO("HangupCall: %s",(ret?"OK":"FAIL")); //TODO switch to message templates window @@ -304,7 +312,7 @@ bool CallWindow::handleCenterButton() { return false; } bool CallWindow::handleRightButton() { - if( state == State::INCOMMING_CALL ) { + if( state == State::INCOMING_CALL ) { auto ret = CellularServiceAPI::HangupCall(application); LOG_INFO("HangupCall: %s",(ret?"OK":"FAIL")); diff --git a/module-apps/application-call/windows/CallWindow.hpp b/module-apps/application-call/windows/CallWindow.hpp index 7c05b1a80..7425d58ae 100644 --- a/module-apps/application-call/windows/CallWindow.hpp +++ b/module-apps/application-call/windows/CallWindow.hpp @@ -22,7 +22,7 @@ class CallWindow: public AppWindow { public: enum class State { IDLE, - INCOMMING_CALL, + INCOMING_CALL, OUTGOING_CALL, CALL_IN_PROGRESS, CALL_ENDED @@ -67,7 +67,9 @@ public: * Used by application to update window's state */ void setState( State state ); + const State& getState(); void updateDuration( uint32_t duration ); + void setCallNumber( std::string ); //virtual methods bool onInput( const InputEvent& inputEvent ) override;