rosterReferences #39
@ -219,6 +219,8 @@ void Core::Account::onClientConnected()
|
|||||||
|
|
||||||
void Core::Account::onClientDisconnected()
|
void Core::Account::onClientDisconnected()
|
||||||
{
|
{
|
||||||
|
cancelHistoryRequests();
|
||||||
|
pendingVCardRequests.clear();
|
||||||
clearConferences();
|
clearConferences();
|
||||||
if (state != Shared::ConnectionState::disconnected) {
|
if (state != Shared::ConnectionState::disconnected) {
|
||||||
if (reconnectTimes > 0) {
|
if (reconnectTimes > 0) {
|
||||||
@ -854,18 +856,20 @@ void Core::Account::onMamMessageReceived(const QString& queryId, const QXmppMess
|
|||||||
{
|
{
|
||||||
if (msg.id().size() > 0 && (msg.body().size() > 0 || msg.outOfBandUrl().size() > 0)) {
|
if (msg.id().size() > 0 && (msg.body().size() > 0 || msg.outOfBandUrl().size() > 0)) {
|
||||||
std::map<QString, QString>::const_iterator itr = achiveQueries.find(queryId);
|
std::map<QString, QString>::const_iterator itr = achiveQueries.find(queryId);
|
||||||
QString jid = itr->second;
|
if (itr != achiveQueries.end()) {
|
||||||
RosterItem* item = getRosterItem(jid);
|
QString jid = itr->second;
|
||||||
|
RosterItem* item = getRosterItem(jid);
|
||||||
Shared::Message sMsg(static_cast<Shared::Message::Type>(msg.type()));
|
|
||||||
initializeMessage(sMsg, msg, false, true, true);
|
Shared::Message sMsg(static_cast<Shared::Message::Type>(msg.type()));
|
||||||
sMsg.setState(Shared::Message::State::sent);
|
initializeMessage(sMsg, msg, false, true, true);
|
||||||
|
sMsg.setState(Shared::Message::State::sent);
|
||||||
QString oId = msg.replaceId();
|
|
||||||
if (oId.size() > 0) {
|
QString oId = msg.replaceId();
|
||||||
item->correctMessageInArchive(oId, sMsg);
|
if (oId.size() > 0) {
|
||||||
} else {
|
item->correctMessageInArchive(oId, sMsg);
|
||||||
item->addMessageToArchive(sMsg);
|
} else {
|
||||||
|
item->addMessageToArchive(sMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -896,10 +900,15 @@ void Core::Account::requestArchive(const QString& jid, int count, const QString&
|
|||||||
|
|
||||||
if (contact == 0) {
|
if (contact == 0) {
|
||||||
qDebug() << "An attempt to request archive for" << jid << "in account" << name << ", but the contact with such id wasn't found, skipping";
|
qDebug() << "An attempt to request archive for" << jid << "in account" << name << ", but the contact with such id wasn't found, skipping";
|
||||||
emit responseArchive(contact->jid, std::list<Shared::Message>());
|
emit responseArchive(jid, std::list<Shared::Message>());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state != Shared::ConnectionState::connected) {
|
||||||
|
qDebug() << "An attempt to request archive for" << jid << "in account" << name << ", but the account is not online, skipping";
|
||||||
|
emit responseArchive(contact->jid, std::list<Shared::Message>());
|
||||||
|
}
|
||||||
|
|
||||||
if (contact->getArchiveState() == RosterItem::empty && before.size() == 0) {
|
if (contact->getArchiveState() == RosterItem::empty && before.size() == 0) {
|
||||||
QXmppMessage msg(getFullJid(), jid, "", "");
|
QXmppMessage msg(getFullJid(), jid, "", "");
|
||||||
QString last = Shared::generateUUID();
|
QString last = Shared::generateUUID();
|
||||||
@ -952,14 +961,16 @@ void Core::Account::onContactNeedHistory(const QString& before, const QString& a
|
|||||||
void Core::Account::onMamResultsReceived(const QString& queryId, const QXmppResultSetReply& resultSetReply, bool complete)
|
void Core::Account::onMamResultsReceived(const QString& queryId, const QXmppResultSetReply& resultSetReply, bool complete)
|
||||||
{
|
{
|
||||||
std::map<QString, QString>::const_iterator itr = achiveQueries.find(queryId);
|
std::map<QString, QString>::const_iterator itr = achiveQueries.find(queryId);
|
||||||
QString jid = itr->second;
|
if (itr != achiveQueries.end()) {
|
||||||
achiveQueries.erase(itr);
|
QString jid = itr->second;
|
||||||
|
achiveQueries.erase(itr);
|
||||||
RosterItem* ri = getRosterItem(jid);
|
|
||||||
|
RosterItem* ri = getRosterItem(jid);
|
||||||
if (ri != 0) {
|
|
||||||
qDebug() << "Flushing messages for" << jid;
|
if (ri != 0) {
|
||||||
ri->flushMessagesToArchive(complete, resultSetReply.first(), resultSetReply.last());
|
qDebug() << "Flushing messages for" << jid;
|
||||||
|
ri->flushMessagesToArchive(complete, resultSetReply.first(), resultSetReply.last());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1743,3 +1754,14 @@ void Core::Account::onReceiptReceived(const QString& jid, const QString& id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::Account::cancelHistoryRequests()
|
||||||
|
{
|
||||||
|
for (const std::pair<QString, Conference*>& pair : conferences) {
|
||||||
|
pair.second->clearArchiveRequests();
|
||||||
|
}
|
||||||
|
for (const std::pair<QString, Contact*>& pair : contacts) {
|
||||||
|
pair.second->clearArchiveRequests();
|
||||||
|
}
|
||||||
|
achiveQueries.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -236,6 +236,7 @@ private:
|
|||||||
void logMessage(const QXmppMessage& msg, const QString& reason = "Message wasn't handled: ");
|
void logMessage(const QXmppMessage& msg, const QString& reason = "Message wasn't handled: ");
|
||||||
void storeConferences();
|
void storeConferences();
|
||||||
void clearConferences();
|
void clearConferences();
|
||||||
|
void cancelHistoryRequests();
|
||||||
void sendMessageWithLocalUploadedFile(Shared::Message msg, const QString& url);
|
void sendMessageWithLocalUploadedFile(Shared::Message msg, const QString& url);
|
||||||
RosterItem* getRosterItem(const QString& jid);
|
RosterItem* getRosterItem(const QString& jid);
|
||||||
};
|
};
|
||||||
|
@ -518,3 +518,13 @@ Shared::VCard Core::RosterItem::handleResponseVCard(const QXmppVCardIq& card, co
|
|||||||
return vCard;
|
return vCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::RosterItem::clearArchiveRequests()
|
||||||
|
{
|
||||||
|
syncronizing = false;
|
||||||
|
requestedCount = 0;
|
||||||
|
requestedBefore = "";
|
||||||
|
hisoryCache.clear();
|
||||||
|
responseCache.clear();
|
||||||
|
appendCache.clear();
|
||||||
|
requestCache.clear();
|
||||||
|
}
|
||||||
|
@ -76,6 +76,7 @@ public:
|
|||||||
virtual void handlePresence(const QXmppPresence& pres) = 0;
|
virtual void handlePresence(const QXmppPresence& pres) = 0;
|
||||||
|
|
||||||
bool changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
bool changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
||||||
|
void clearArchiveRequests();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nameChanged(const QString& name);
|
void nameChanged(const QString& name);
|
||||||
|
Loading…
Reference in New Issue
Block a user