handled a case when user removes downloaded file, minor optimizations on message changing
This commit is contained in:
parent
b44873d587
commit
50190f3eac
23 changed files with 136 additions and 40 deletions
|
@ -920,3 +920,6 @@ void Core::Account::onContactHistoryResponse(const std::list<Shared::Message>& l
|
|||
}
|
||||
emit responseArchive(contact->jid, list, last);
|
||||
}
|
||||
|
||||
void Core::Account::requestChangeMessage(const QString& jid, const QString& messageId, const QMap<QString, QVariant>& data){
|
||||
mh->requestChangeMessage(jid, messageId, data);}
|
||||
|
|
|
@ -96,6 +96,7 @@ public:
|
|||
void addContactToGroupRequest(const QString& jid, const QString& groupName);
|
||||
void removeContactFromGroupRequest(const QString& jid, const QString& groupName);
|
||||
void renameContactRequest(const QString& jid, const QString& newName);
|
||||
void requestChangeMessage(const QString& jid, const QString& messageId, const QMap<QString, QVariant>& data);
|
||||
|
||||
void setRoomJoined(const QString& jid, bool joined);
|
||||
void setRoomAutoJoin(const QString& jid, bool joined);
|
||||
|
|
|
@ -429,3 +429,18 @@ void Core::MessageHandler::sendMessageWithLocalUploadedFile(Shared::Message msg,
|
|||
performSending(msg);
|
||||
//TODO removal/progress update
|
||||
}
|
||||
|
||||
void Core::MessageHandler::requestChangeMessage(const QString& jid, const QString& messageId, const QMap<QString, QVariant>& data)
|
||||
{
|
||||
RosterItem* cnt = acc->rh->getRosterItem(jid);
|
||||
if (cnt != 0) {
|
||||
QMap<QString, QVariant>::const_iterator itr = data.find("attachPath");
|
||||
if (data.size() == 1 && itr != data.end()) {
|
||||
cnt->changeMessage(messageId, data);
|
||||
emit acc->changeMessage(jid, messageId, data);
|
||||
} else {
|
||||
qDebug() << "A request to change message" << messageId << "of conversation" << jid << "with following data" << data;
|
||||
qDebug() << "nothing but the changing of the local path is supported yet in this method, skipping";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ public slots:
|
|||
void onDownloadFileComplete(const std::list<Shared::MessageInfo>& msgs, const QString& path);
|
||||
void onUploadFileComplete(const std::list<Shared::MessageInfo>& msgs, const QString& path);
|
||||
void onLoadFileError(const std::list<Shared::MessageInfo>& msgs, const QString& path, bool up);
|
||||
void requestChangeMessage(const QString& jid, const QString& messageId, const QMap<QString, QVariant>& data);
|
||||
|
||||
private:
|
||||
bool handleChatMessage(const QXmppMessage& msg, bool outgoing = false, bool forwarded = false, bool guessing = false);
|
||||
|
|
|
@ -493,3 +493,8 @@ QString Core::NetworkAccess::addMessageAndCheckForPath(const QString& url, const
|
|||
{
|
||||
return storage.addMessageAndCheckForPath(url, account, jid, id);
|
||||
}
|
||||
|
||||
std::list<Shared::MessageInfo> Core::NetworkAccess::reportPathInvalid(const QString& path)
|
||||
{
|
||||
return storage.deletedFile(path);
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
QString addMessageAndCheckForPath(const QString& url, const QString& account, const QString& jid, const QString& id);
|
||||
void uploadFile(const Shared::MessageInfo& info, const QString& path, const QUrl& put, const QUrl& get, const QMap<QString, QString> headers);
|
||||
bool checkAndAddToUploading(const QString& acc, const QString& jid, const QString id, const QString path);
|
||||
std::list<Shared::MessageInfo> reportPathInvalid(const QString& path);
|
||||
|
||||
signals:
|
||||
void loadFileProgress(const std::list<Shared::MessageInfo>& msgs, qreal value, bool up);
|
||||
|
|
|
@ -751,3 +751,20 @@ void Core::Squawk::onAccountUploadFileError(const QString& jid, const QString id
|
|||
Account* acc = static_cast<Account*>(sender());
|
||||
emit fileError({{acc->getName(), jid, id}}, errorText, true);
|
||||
}
|
||||
|
||||
void Core::Squawk::onLocalPathInvalid(const QString& path)
|
||||
{
|
||||
std::list<Shared::MessageInfo> list = network.reportPathInvalid(path);
|
||||
|
||||
QMap<QString, QVariant> data({
|
||||
{"attachPath", ""}
|
||||
});
|
||||
for (const Shared::MessageInfo& info : list) {
|
||||
AccountsMap::const_iterator itr = amap.find(info.account);
|
||||
if (itr != amap.end()) {
|
||||
itr->second->requestChangeMessage(info.jid, info.messageId, data);
|
||||
} else {
|
||||
qDebug() << "Reacting on failure to reach file" << path << "there was an attempt to change message in account" << info.account << "which doesn't exist, skipping";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ public slots:
|
|||
void requestVCard(const QString& account, const QString& jid);
|
||||
void uploadVCard(const QString& account, const Shared::VCard& card);
|
||||
void responsePassword(const QString& account, const QString& password);
|
||||
void onLocalPathInvalid(const QString& path);
|
||||
|
||||
private:
|
||||
typedef std::deque<Account*> Accounts;
|
||||
|
|
|
@ -348,6 +348,7 @@ std::list<Shared::MessageInfo> Core::UrlStorage::deletedFile(const QString& path
|
|||
url = QString(surl.c_str());
|
||||
} else if (rc == MDB_NOTFOUND) {
|
||||
qDebug() << "Have been asked to remove file" << path << ", which isn't in the database, skipping";
|
||||
mdb_txn_abort(txn);
|
||||
return list;
|
||||
} else {
|
||||
throw Archive::Unknown(name.toStdString(), mdb_strerror(rc));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue