| 793 | } |
| 794 | |
| 795 | void Client::protocolClientOnConnectToFinished(int errCode, QString message) { |
| 796 | LOGGER_DEBUG("In Client: protocolClientOnConnectToFinished({}, {})", errCode, message.toStdString()); |
| 797 | uiFocusOnOverviewTab(); |
| 798 | if (errCode == 0) { |
| 799 | m_connectionState = ConnectionState::STATE_CONNECTED; |
| 800 | m_ui->btnConnect->setText(tr("Disconnect")); |
| 801 | m_ui->btnConnect->setEnabled(true); |
| 802 | |
| 803 | // Start checking feature levels and statuses of contacts |
| 804 | if (m_databaseThread.getWorker().hasDatabase()) { |
| 805 | QSet<openmittsu::protocol::ContactId> const contactsRequiringAccountStatusCheck = m_databaseWrapper.getContactsRequiringAccountStatusCheck(86400); |
| 806 | QSet<openmittsu::protocol::ContactId> const contactsRequiringFeatureLevelCheck = m_databaseWrapper.getContactsRequiringFeatureLevelCheck(86400); |
| 807 | |
| 808 | if (contactsRequiringFeatureLevelCheck.size() > 0) { |
| 809 | openmittsu::tasks::CheckFeatureLevelCallbackTask* taskCheckFeatureLevels = new openmittsu::tasks::CheckFeatureLevelCallbackTask(m_serverConfiguration, contactsRequiringFeatureLevelCheck); |
| 810 | OPENMITTSU_CONNECT_QUEUED(taskCheckFeatureLevels, finished(openmittsu::tasks::CallbackTask*), this, callbackTaskFinished(openmittsu::tasks::CallbackTask*)); |
| 811 | taskCheckFeatureLevels->start(); |
| 812 | } |
| 813 | |
| 814 | if (contactsRequiringAccountStatusCheck.size() > 0) { |
| 815 | openmittsu::tasks::CheckContactActivityStatusCallbackTask* taskCheckContactIdStatus = new openmittsu::tasks::CheckContactActivityStatusCallbackTask(m_serverConfiguration, contactsRequiringAccountStatusCheck); |
| 816 | OPENMITTSU_CONNECT_QUEUED(taskCheckContactIdStatus, finished(openmittsu::tasks::CallbackTask*), this, callbackTaskFinished(openmittsu::tasks::CallbackTask*)); |
| 817 | taskCheckContactIdStatus->start(); |
| 818 | } |
| 819 | } |
| 820 | } else { |
| 821 | m_connectionState = ConnectionState::STATE_DISCONNECTED; |
| 822 | LOGGER()->warn("Could not connect to server. The error was: {}", message.toStdString()); |
| 823 | QMessageBox::warning(this, "Connection Error", QString("Could not connect to server.\nThe error was: %1").arg(message)); |
| 824 | m_ui->btnConnect->setText(tr("Connect")); |
| 825 | m_ui->btnConnect->setEnabled(true); |
| 826 | } |
| 827 | } |
| 828 | |
| 829 | void Client::uiFocusOnOverviewTab() { |
| 830 | m_ui->tabWidget->setCurrentWidget(m_ui->tabOverview); |
nothing calls this directly
no test coverage detected