[EGD-3542] Fix issue with sending text messages form new message window Fixed too short timeout for sending sms Fixed flow for switching to thred window to asynchornous one Fixed some minor issues connected to new sms error handling
7 files changed, 35 insertions(+), 61 deletions(-) M module-apps/application-messages/windows/NewMessage.cpp M module-apps/application-messages/windows/NewMessage.hpp M module-cellular/at/src/ATFactory.cpp M module-services/service-cellular/ServiceCellular.cpp M module-services/service-db/DBServiceAPI.cpp M module-services/service-db/service-db/DBServiceAPI.hpp M module-services/service-desktop/tests/test-contacts.cpp
M module-apps/application-messages/windows/NewMessage.cpp => module-apps/application-messages/windows/NewMessage.cpp +21 -14
@@ 126,6 126,7 @@ namespace gui LOG_ERROR("Failed to send the SMS."); return false; } setFocusItem(nullptr); // to make sure it is not possible to send text message multiple times return switchToThreadWindow(number.getView()); } @@ 142,22 143,28 @@ namespace gui bool NewMessageWindow::switchToThreadWindow(const utils::PhoneNumber::View &number) { auto thread = DBServiceAPI::ThreadGetByNumber(application, number, getThreadTimeout.count()); if (!thread) { LOG_FATAL("No thread and thread not created!"); return false; } auto query = std::make_unique<db::query::ThreadGetByNumber>(number); auto task = app::AsyncQuery::createFromQuery(std::move(query), db::Interface::Name::SMSThread); task->setCallback([this](auto response) { const auto result = dynamic_cast<db::query::ThreadGetByNumberResult *>(response); if (result == nullptr) { return false; } // clear data only when message is sent contact = nullptr; phoneNumber.clear(); recipient->clear(); message->clear(); setFocusItem(body); // clear data only when message is sent contact = nullptr; phoneNumber.clear(); recipient->clear(); message->clear(); setFocusItem(body); const auto &thread = result->getThread(); auto switchData = std::make_unique<SMSThreadData>(std::make_unique<ThreadRecord>(thread)); switchData->ignoreCurrentWindowOnStack = true; application->switchWindow(gui::name::window::thread_view, std::move(switchData)); return true; }); task->execute(application, this); auto switchData = std::make_unique<SMSThreadData>(std::move(thread)); switchData->ignoreCurrentWindowOnStack = true; application->switchWindow(gui::name::window::thread_view, std::move(switchData)); return true; }
M module-apps/application-messages/windows/NewMessage.hpp => module-apps/application-messages/windows/NewMessage.hpp +0 -1
@@ 38,7 38,6 @@ namespace gui -> bool; void storeMessageDraft(const utils::PhoneNumber::View &number, const UTF8 &text); void storeMessageDraft(SMSRecord &sms, const UTF8 &text); static inline constexpr std::chrono::milliseconds getThreadTimeout{1000}; gui::Text *recipient = nullptr; gui::Text *message = nullptr; gui::VBox *body = nullptr;
M module-cellular/at/src/ATFactory.cpp => module-cellular/at/src/ATFactory.cpp +10 -10
@@ 28,7 28,7 @@ namespace at {AT::CRC_ON, {"AT+CRC=1"}}, {AT::CALLER_NUMBER_PRESENTATION, {"AT+CLIP=1", default_long_timeout}}, {AT::SMS_TEXT_FORMAT, {"AT+CMGF=1"}}, {AT::SMS_UCSC2, {"AT+CSCS=\"UCS2\"", 1s}}, {AT::SMS_UCSC2, {"AT+CSCS=\"UCS2\""}}, {AT::SMS_GSM, {"AT+CSCS=\"GSM\""}}, {AT::QSCLK_ON, {"AT+QSCLK=1"}}, {AT::QDAI, {"AT+QDAI?"}}, @@ 39,9 39,9 @@ namespace at {AT::CMGD, {"AT+CMGD="}}, {AT::CNUM, {"AT+CNUM"}}, {AT::CIMI, {"AT+CIMI"}}, {AT::QCMGR, {"AT+QCMGR=", 12s}}, {AT::ATH, {"ATH", 90s}}, {AT::ATA, {"ATA", 90s}}, {AT::QCMGR, {"AT+QCMGR=", 180s}}, {AT::ATH, {"ATH", 100s}}, {AT::ATA, {"ATA", 100s}}, {AT::ATD, {"ATD", 6s}}, {AT::IPR, {"AT+IPR="}}, {AT::CMUX, {"AT+CMUX="}}, @@ 50,11 50,11 @@ namespace at {AT::CFUN_MIN_FUNCTIONALITY, {"AT+CFUN=0", default_long_timeout}}, {AT::CFUN_FULL_FUNCTIONALITY, {"AT+CFUN=1", default_long_timeout}}, {AT::CFUN_DISABLE_TRANSMITTING, {"AT+CFUN=4", default_long_timeout}}, {AT::CMGS, {"AT+CMGS=\"", 120s}}, // verified in docs {AT::QCMGS, {"AT+QCMGS=\"", 120s}}, // verified in docs {AT::CMGS, {"AT+CMGS=\"", 180s}}, // {AT::QCMGS, {"AT+QCMGS=\"", 180s}}, {AT::CREG, {"AT+CREG?"}}, {AT::QNWINFO, {"AT+QNWINFO"}}, {AT::COPS, {"AT+COPS", 180s}}, {AT::COPS, {"AT+COPS", 200s}}, {AT::QSIMSTAT, {"AT+QSIMSTAT?"}}, {AT::SIM_DET, {"AT+QSIMDET?"}}, {AT::SIM_DET_ON, {"AT+QSIMDET=1,0"}}, @@ 67,9 67,9 @@ namespace at {AT::QIGETERROR, {"AT+QIGETERROR"}}, {AT::VTS, {"AT+VTS=", default_long_timeout}}, {AT::QLDTMF, {"AT+QLDTMF=1,"}}, {AT::CUSD_OPEN_SESSION, {"AT+CUSD=1", 120s}}, {AT::CUSD_CLOSE_SESSION, {"AT+CUSD=2", 120s}}, {AT::CUSD_SEND, {"AT+CUSD=1,", 120s}}, {AT::CUSD_OPEN_SESSION, {"AT+CUSD=1", 150s}}, {AT::CUSD_CLOSE_SESSION, {"AT+CUSD=2", 150s}}, {AT::CUSD_SEND, {"AT+CUSD=1,", 150s}}, {AT::SET_SMS_STORAGE, {"AT+CPMS=\"SM\",\"SM\",\"SM\""}}, {AT::CPIN, {"AT+CPIN=", default_long_timeout}}, {AT::GET_CPIN, {"AT+CPIN?", default_long_timeout}},
M module-services/service-cellular/ServiceCellular.cpp => module-services/service-cellular/ServiceCellular.cpp +4 -4
@@ 986,7 986,7 @@ bool ServiceCellular::handle_audio_conf_procedure() auto ServiceCellular::handle(db::query::SMSSearchByTypeResult *response) -> bool { if (response->getResults().size() > 0) { LOG_DEBUG("sending %ud last queued message(s)", static_cast<unsigned int>(response->getResults().size())); LOG_DEBUG("sending %u last queued message(s)", static_cast<unsigned int>(response->getResults().size())); if (Store::GSM::get()->simCardInserted() == false) { auto message = std::make_shared<CellularSmsNoSimRequestMessage>(); bus.sendUnicast(std::move(message), app::manager::ApplicationManager::ServiceName); @@ 1378,10 1378,10 @@ auto ServiceCellular::sendSMS(SMSRecord record) -> bool record.type = SMSType::OUTBOX; } else { LOG_INFO("SMS sending failed."); LOG_ERROR("SMS sending failed."); record.type = SMSType::FAILED; if (checkSmsCenter(*channel)) { LOG_ERROR("SMS center check"); if (!checkSmsCenter(*channel)) { LOG_ERROR("SMS center check failed"); } } DBServiceAPI::GetQuery(this, db::Interface::Name::SMS, std::make_unique<db::query::SMSUpdate>(std::move(record)));
M module-services/service-db/DBServiceAPI.cpp => module-services/service-db/DBServiceAPI.cpp +0 -21
@@ 26,27 26,6 @@ struct NotesRecord; auto DBServiceAPI::ThreadGetByNumber(sys::Service *serv, const utils::PhoneNumber::View &phoneNumber, std::uint32_t timeout) -> std::unique_ptr<ThreadRecord> { auto [code, msg] = DBServiceAPI::GetQueryWithReply( serv, db::Interface::Name::SMSThread, std::make_unique<db::query::ThreadGetByNumber>(phoneNumber), timeout); if (code == sys::ReturnCodes::Success && msg != nullptr) { auto queryResponse = dynamic_cast<db::QueryResponse *>(msg.get()); assert(queryResponse != nullptr); auto threadResponse = queryResponse->getResult(); auto threadResult = dynamic_cast<db::query::ThreadGetByNumberResult *>(threadResponse.get()); assert(threadResult != nullptr); return std::make_unique<ThreadRecord>(threadResult->getThread()); } return nullptr; } auto DBServiceAPI::ContactGetByID(sys::Service *serv, uint32_t contactID) -> std::unique_ptr<std::vector<ContactRecord>> { ContactRecord rec;
M module-services/service-db/service-db/DBServiceAPI.hpp => module-services/service-db/service-db/DBServiceAPI.hpp +0 -5
@@ 47,11 47,6 @@ class DBServiceAPI success }; [[deprecated]] static auto ThreadGetByNumber(sys::Service *serv, const utils::PhoneNumber::View &phoneNumber, std::uint32_t timeout = DefaultTimeoutInMs) -> std::unique_ptr<ThreadRecord>; /** * Queries the database. * @param serv Sender service.
M module-services/service-desktop/tests/test-contacts.cpp => module-services/service-desktop/tests/test-contacts.cpp +0 -6
@@ 35,12 35,6 @@ std::pair<bool, std::uint64_t> DBServiceAPI::GetQuery(sys::Service *serv, return std::make_pair(true, 0); } auto DBServiceAPI::ThreadGetByNumber(sys::Service *serv, const utils::PhoneNumber::View &phoneNumber, std::uint32_t timeout) -> std::unique_ptr<ThreadRecord> { return nullptr; } auto DBServiceAPI::GetQueryWithReply(sys::Service *serv, db::Interface::Name database,