forked from blue/squawk
support of the new managers in account code, new states, new lambdas, even launches now, even receives some bundles
This commit is contained in:
parent
db3bc358a7
commit
dfe72ca36c
12 changed files with 113 additions and 25 deletions
|
@ -51,6 +51,7 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
|
|||
um(new QXmppUploadRequestManager()),
|
||||
dm(client.findExtension<QXmppDiscoveryManager>()),
|
||||
rcpm(new QXmppMessageReceiptManager()),
|
||||
psm(new QXmppPubSubManager()),
|
||||
reconnectScheduled(false),
|
||||
reconnectTimer(new QTimer),
|
||||
network(p_net),
|
||||
|
@ -58,7 +59,8 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
|
|||
lastError(Error::none),
|
||||
pepSupport(Shared::Support::unknown),
|
||||
active(p_active),
|
||||
notReadyPassword(false)
|
||||
notReadyPassword(false),
|
||||
loadingOmemo(false)
|
||||
{
|
||||
config.setUser(p_login);
|
||||
config.setDomain(p_server);
|
||||
|
@ -99,10 +101,31 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
|
|||
client.addExtension(rcpm);
|
||||
QObject::connect(rcpm, &QXmppMessageReceiptManager::messageDelivered, mh, &MessageHandler::onReceiptReceived);
|
||||
|
||||
client.addExtension(psm);
|
||||
|
||||
#ifdef WITH_OMEMO
|
||||
client.addExtension(tm);
|
||||
client.addExtension(om);
|
||||
qDebug("Added OMEMO manager");
|
||||
|
||||
if (oh->hasOwnDevice()) {
|
||||
QFuture<bool> future = om->load();
|
||||
loadingOmemo = true;
|
||||
|
||||
QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>(this);
|
||||
QObject::connect(watcher, &QFutureWatcherBase::finished, [watcher, this] () {
|
||||
loadingOmemo = false;
|
||||
if (state == Shared::ConnectionState::scheduled) {
|
||||
client.connectToServer(config, presence);
|
||||
}
|
||||
if (watcher->result()) {
|
||||
qDebug() << "successfully loaded OMEMO data for account" << getName();
|
||||
} else {
|
||||
qDebug() << "couldn't load OMEMO data for account" << getName();
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
watcher->setFuture(future);
|
||||
}
|
||||
#endif
|
||||
|
||||
reconnectTimer->setSingleShot(true);
|
||||
|
@ -162,7 +185,12 @@ void Core::Account::connect()
|
|||
if (notReadyPassword) {
|
||||
emit needPassword();
|
||||
} else {
|
||||
client.connectToServer(config, presence);
|
||||
if (loadingOmemo) {
|
||||
state = Shared::ConnectionState::scheduled;
|
||||
emit connectionStateChanged(state);
|
||||
} else {
|
||||
client.connectToServer(config, presence);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -186,7 +214,12 @@ void Core::Account::disconnect()
|
|||
}
|
||||
if (state != Shared::ConnectionState::disconnected) {
|
||||
//rh->clearConferences();
|
||||
client.disconnectFromServer();
|
||||
if (state != Shared::ConnectionState::scheduled) {
|
||||
client.disconnectFromServer();
|
||||
} else {
|
||||
state = Shared::ConnectionState::disconnected;
|
||||
emit connectionStateChanged(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,9 +232,29 @@ 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());
|
||||
#ifdef WITH_OMEMO
|
||||
if (!oh->hasOwnDevice()) {
|
||||
qDebug() << "setting up OMEMO data for account" << getName();
|
||||
QFuture<bool> future = om->setUp();
|
||||
QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>(this);
|
||||
QObject::connect(watcher, &QFutureWatcherBase::finished, [watcher, this] () {
|
||||
if (watcher->result()) {
|
||||
qDebug() << "successfully set up OMEMO data for account" << getName();
|
||||
} else {
|
||||
qDebug() << "couldn't set up OMEMO data for account" << getName();
|
||||
}
|
||||
watcher->deleteLater();
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
runDiscoveryService();
|
||||
}
|
||||
});
|
||||
watcher->setFuture(future);
|
||||
} else {
|
||||
runDiscoveryService();
|
||||
}
|
||||
#else
|
||||
runDiscoveryService();
|
||||
#endif
|
||||
}
|
||||
lastError = Error::none;
|
||||
emit connectionStateChanged(state);
|
||||
|
@ -270,6 +323,13 @@ void Core::Account::setAvailability(Shared::Availability avail)
|
|||
}
|
||||
}
|
||||
|
||||
void Core::Account::runDiscoveryService() {
|
||||
qDebug() << "running service discovery for account" << name;
|
||||
dm->requestItems(getServer());
|
||||
dm->requestInfo(getServer());
|
||||
}
|
||||
|
||||
|
||||
void Core::Account::onPresenceReceived(const QXmppPresence& p_presence)
|
||||
{
|
||||
QString id = p_presence.from();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue