first working prototype of file upload

This commit is contained in:
Blue 2019-11-12 16:38:01 +03:00
parent a6e48599aa
commit 166a7ac83a
13 changed files with 244 additions and 97 deletions

View file

@ -369,11 +369,11 @@ void Squawk::onConversationDownloadFile(const QString& messageId, const QString&
}
}
void Squawk::downloadFileProgress(const QString& messageId, qreal value)
void Squawk::fileProgress(const QString& messageId, qreal value)
{
std::map<QString, std::set<Models::Roster::ElId>>::const_iterator itr = requestedFiles.find(messageId);
if (itr == requestedFiles.end()) {
qDebug() << "downloadFileProgress in UI Squawk but there is nobody waiting for that id" << messageId << ", skipping";
qDebug() << "fileProgress in UI Squawk but there is nobody waiting for that id" << messageId << ", skipping";
return;
} else {
const std::set<Models::Roster::ElId>& convs = itr->second;
@ -381,17 +381,17 @@ void Squawk::downloadFileProgress(const QString& messageId, qreal value)
const Models::Roster::ElId& id = *cItr;
Conversations::const_iterator c = conversations.find(id);
if (c != conversations.end()) {
c->second->responseDownloadProgress(messageId, value);
c->second->responseFileProgress(messageId, value);
}
}
}
}
void Squawk::downloadFileError(const QString& messageId, const QString& error)
void Squawk::fileError(const QString& messageId, const QString& error)
{
std::map<QString, std::set<Models::Roster::ElId>>::const_iterator itr = requestedFiles.find(messageId);
if (itr == requestedFiles.end()) {
qDebug() << "downloadFileError in UI Squawk but there is nobody waiting for that id" << messageId << ", skipping";
qDebug() << "fileError in UI Squawk but there is nobody waiting for that id" << messageId << ", skipping";
return;
} else {
const std::set<Models::Roster::ElId>& convs = itr->second;
@ -399,7 +399,7 @@ void Squawk::downloadFileError(const QString& messageId, const QString& error)
const Models::Roster::ElId& id = *cItr;
Conversations::const_iterator c = conversations.find(id);
if (c != conversations.end()) {
c->second->downloadError(messageId, error);
c->second->fileError(messageId, error);
}
}
requestedFiles.erase(itr);
@ -497,6 +497,9 @@ void Squawk::onConversationMessage(const Shared::Message& msg)
void Squawk::onConversationMessage(const Shared::Message& msg, const QString& path)
{
Conversation* conv = static_cast<Conversation*>(sender());
std::map<QString, std::set<Models::Roster::ElId>>::iterator itr = requestedFiles.insert(std::make_pair(msg.getId(), std::set<Models::Roster::ElId>())).first;
itr->second.insert(Models::Roster::ElId(conv->getAccount(), conv->getJid()));
emit sendMessage(conv->getAccount(), msg, path);
}