Port away from QNetworkConfigurationManager
QNetworkConfigurationManager was removed from Qt6 and it's better to check the status of the sync job anyway. Only two issues: * The timeout in quotient is quite high so it might take up to one minute before the message appear. * Only sync job are listened but since they are continuously done, this is not a big issue and other job are affected by the same issue of an high timeout anyway. Fix #414
This commit is contained in:
@@ -60,7 +60,6 @@ using namespace Quotient;
|
|||||||
|
|
||||||
Controller::Controller(QObject *parent)
|
Controller::Controller(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_mgr(new QNetworkConfigurationManager(this))
|
|
||||||
{
|
{
|
||||||
Connection::setRoomType<NeoChatRoom>();
|
Connection::setRoomType<NeoChatRoom>();
|
||||||
Connection::setUserType<NeoChatUser>();
|
Connection::setUserType<NeoChatUser>();
|
||||||
@@ -115,8 +114,6 @@ Controller::Controller(QObject *parent)
|
|||||||
sigaction(sig, &sa, nullptr);
|
sigaction(sig, &sa, nullptr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
connect(m_mgr, &QNetworkConfigurationManager::onlineStateChanged, this, &Controller::isOnlineChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller::~Controller()
|
Controller::~Controller()
|
||||||
@@ -563,9 +560,26 @@ void Controller::setActiveConnection(Connection *connection)
|
|||||||
if (connection == m_connection) {
|
if (connection == m_connection) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (m_connection != nullptr) {
|
||||||
|
disconnect(connection, &Connection::syncError, this, nullptr);
|
||||||
|
}
|
||||||
m_connection = connection;
|
m_connection = connection;
|
||||||
if (connection != nullptr) {
|
if (connection != nullptr) {
|
||||||
NeoChatConfig::self()->setActiveConnection(connection->userId());
|
NeoChatConfig::self()->setActiveConnection(connection->userId());
|
||||||
|
connect(connection, &Connection::networkError, this, [this](QString message, QString details, int retriesTaken, int nextRetryInMilliseconds) {
|
||||||
|
if (!m_isOnline) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_isOnline = false;
|
||||||
|
Q_EMIT isOnlineChanged(false);
|
||||||
|
});
|
||||||
|
connect(connection, &Connection::syncDone, this, [this] {
|
||||||
|
if (m_isOnline) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_isOnline = true;
|
||||||
|
Q_EMIT isOnlineChanged(true);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
NeoChatConfig::self()->setActiveConnection(QString());
|
NeoChatConfig::self()->setActiveConnection(QString());
|
||||||
}
|
}
|
||||||
@@ -612,7 +626,7 @@ void Controller::createRoom(const QString &name, const QString &topic)
|
|||||||
|
|
||||||
bool Controller::isOnline() const
|
bool Controller::isOnline() const
|
||||||
{
|
{
|
||||||
return m_mgr->isOnline();
|
return m_isOnline;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove in favor of RoomManager::joinRoom
|
// TODO: Remove in favor of RoomManager::joinRoom
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include <KFormat>
|
#include <KFormat>
|
||||||
|
|
||||||
class QKeySequences;
|
class QKeySequences;
|
||||||
class QNetworkConfigurationManager;
|
|
||||||
|
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "csapi/list_public_rooms.h"
|
#include "csapi/list_public_rooms.h"
|
||||||
@@ -107,6 +106,7 @@ private:
|
|||||||
|
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
void saveSettings() const;
|
void saveSettings() const;
|
||||||
|
bool m_isOnline = true;
|
||||||
|
|
||||||
KAboutData m_aboutData;
|
KAboutData m_aboutData;
|
||||||
bool hasWindowSystem() const;
|
bool hasWindowSystem() const;
|
||||||
@@ -143,9 +143,6 @@ public Q_SLOTS:
|
|||||||
static void markAllMessagesAsRead(Quotient::Connection *conn);
|
static void markAllMessagesAsRead(Quotient::Connection *conn);
|
||||||
void restoreWindowGeometry(QQuickWindow *);
|
void restoreWindowGeometry(QQuickWindow *);
|
||||||
void saveWindowGeometry(QQuickWindow *);
|
void saveWindowGeometry(QQuickWindow *);
|
||||||
|
|
||||||
private:
|
|
||||||
QNetworkConfigurationManager *m_mgr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO libQuotient 0.7: Drop
|
// TODO libQuotient 0.7: Drop
|
||||||
|
|||||||
Reference in New Issue
Block a user