reconnection issues

This commit is contained in:
Blue 2020-08-08 02:33:03 +03:00
parent 5f64321c2a
commit 3a120c773a
7 changed files with 67 additions and 30 deletions

View File

@ -1,5 +1,13 @@
# Changelog
## Squawk 0.2.0 (Unreleased)
### Bug fixes
- carbon copies switches on again after reconnection
- requesting the history of the current chat after reconnection
- global availability (in drop down list) gets restored after reconnection
- status icon in active chat changes when presence of the pen pal changes
## Squawk 0.1.5 (Jul 29, 2020)
### Bug fixes
- error with sending attached files to the conference

View File

@ -183,7 +183,6 @@ void Core::Account::connect()
reconnectTimer->stop();
}
if (state == Shared::ConnectionState::disconnected) {
qDebug() << presence.availableStatusType();
client.connectToServer(config, presence);
} else {
qDebug("An attempt to connect an account which is already connected, skipping");
@ -219,6 +218,7 @@ void Core::Account::onClientStateChange(QXmppClient::State st)
Shared::ConnectionState os = state;
state = Shared::ConnectionState::connected;
if (os == Shared::ConnectionState::connecting) {
qDebug() << "running service discovery for account" << name;
dm->requestItems(getServer());
dm->requestInfo(getServer());
}
@ -238,9 +238,8 @@ void Core::Account::onClientStateChange(QXmppClient::State st)
}
break;
case QXmppClient::DisconnectedState: {
cancelHistoryRequests();
pendingVCardRequests.clear();
if (state != Shared::ConnectionState::disconnected) {
handleDisconnection();
state = Shared::ConnectionState::disconnected;
emit connectionStateChanged(state);
} else {
@ -887,15 +886,18 @@ void Core::Account::onDiscoveryItemsReceived(const QXmppDiscoveryIq& items)
void Core::Account::onDiscoveryInfoReceived(const QXmppDiscoveryIq& info)
{
qDebug() << "Discovery info received for account" << name;
if (info.from() == getServer()) {
if (info.features().contains("urn:xmpp:carbons:2")) {
qDebug() << "Enabling carbon copies for account" << name;
cm->setCarbonsEnabled(true);
}
}
}
void Core::Account::cancelHistoryRequests()
void Core::Account::handleDisconnection()
{
cm->setCarbonsEnabled(false);
rh->handleOffline();
archiveQueries.clear();
pendingVCardRequests.clear();
@ -903,6 +905,7 @@ void Core::Account::cancelHistoryRequests()
for (const QString& jid : pendingVCardRequests) {
emit receivedVCard(jid, vCard); //need to show it better in the future, like with an error
}
pendingVCardRequests.clear();
ownVCardRequestInProgress = false;
}

View File

@ -185,7 +185,7 @@ private slots:
void onDiscoveryInfoReceived (const QXmppDiscoveryIq& info);
private:
void cancelHistoryRequests();
void handleDisconnection();
void onReconnectTimer();
};

View File

@ -223,30 +223,40 @@ void Core::Squawk::onAccountConnectionStateChanged(Shared::ConnectionState p_sta
Account* acc = static_cast<Account*>(sender());
emit changeAccount(acc->getName(), {{"state", QVariant::fromValue(p_state)}});
switch (p_state) {
case Shared::ConnectionState::disconnected: {
bool equals = true;
for (Accounts::const_iterator itr = accounts.begin(), end = accounts.end(); itr != end; itr++) {
if ((*itr)->getState() != Shared::ConnectionState::disconnected) {
equals = false;
}
}
if (equals && state != Shared::Availability::offline) {
state = Shared::Availability::offline;
emit stateChanged(state);
}
}
break;
case Shared::ConnectionState::connected:
#ifdef WITH_KWALLET
if (acc->getPasswordType() == Shared::AccountPassword::kwallet && kwallet.supportState() == PSE::KWallet::success) {
kwallet.requestWritePassword(acc->getName(), acc->getPassword(), true);
}
#endif
break;
default:
break;
if (p_state == Shared::ConnectionState::connected) {
if (acc->getPasswordType() == Shared::AccountPassword::kwallet && kwallet.supportState() == PSE::KWallet::success) {
kwallet.requestWritePassword(acc->getName(), acc->getPassword(), true);
}
}
#endif
Accounts::const_iterator itr = accounts.begin();
bool es = true;
bool ea = true;
Shared::ConnectionState cs = (*itr)->getState();
Shared::Availability av = (*itr)->getAvailability();
itr++;
for (Accounts::const_iterator end = accounts.end(); itr != end; itr++) {
Account* item = *itr;
if (item->getState() != cs) {
es = false;
}
if (item->getAvailability() != av) {
ea = false;
}
}
if (es) {
if (cs == Shared::ConnectionState::disconnected) {
state = Shared::Availability::offline;
emit stateChanged(state);
} else if (ea) {
state = av;
emit stateChanged(state);
}
}
}
void Core::Squawk::onAccountAddContact(const QString& jid, const QString& group, const QMap<QString, QVariant>& data)

View File

@ -215,9 +215,8 @@ void Models::Item::_removeChild(int index)
void Models::Item::changed(int col)
{
if (parent != nullptr) {
emit childChanged(this, row(), col);
}
emit childChanged(this, row(), col);
}
void Models::Item::toOfflineState()

View File

@ -54,6 +54,8 @@ Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, c
{
m_ui->setupUi(this);
connect(acc, &Models::Account::childChanged, this, &Conversation::onAccountChanged);
filesLayout = new FlowLayout(m_ui->filesPanel, 0);
m_ui->filesPanel->setLayout(filesLayout);
@ -121,6 +123,20 @@ Conversation::~Conversation()
{
}
void Conversation::onAccountChanged(Models::Item* item, int row, int col)
{
if (item == account) {
if (col == 2 && account->getState() == Shared::ConnectionState::connected) {
if (!requestingHistory) {
requestingHistory = true;
line->showBusyIndicator();
emit requestArchive("");
scroll = down;
}
}
}
}
void Conversation::applyVisualEffects()
{
DropShadowEffect *e1 = new DropShadowEffect;

View File

@ -121,6 +121,7 @@ protected slots:
void onBadgeClose();
void onClearButton();
void onTextEditDocSizeChanged(const QSizeF& size);
void onAccountChanged(Models::Item* item, int row, int col);
public:
const bool isMuc;