diff options
| author | Linus Jahn <lnj@kaidan.im> | 2022-10-02 03:52:21 +0200 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2022-10-02 23:01:13 +0200 |
| commit | 2f6a91642f2585c8b226011a0bb5a3725a012b15 (patch) | |
| tree | aaaa82631dd4d2cb2de0c5cb49ec108ff7c8a1b4 /src/client/QXmppFileSharingManager.cpp | |
| parent | d11198502e3bbc7838443147a6dc729f5d1b597d (diff) | |
Make EncryptedHttpFileSharingProvider able to handle not just http
However it is still limited by the sources supported by
EncryptedHttpFileSource.
Diffstat (limited to 'src/client/QXmppFileSharingManager.cpp')
| -rw-r--r-- | src/client/QXmppFileSharingManager.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/client/QXmppFileSharingManager.cpp b/src/client/QXmppFileSharingManager.cpp index 30c0ac1e..fc73099c 100644 --- a/src/client/QXmppFileSharingManager.cpp +++ b/src/client/QXmppFileSharingManager.cpp @@ -312,13 +312,11 @@ std::shared_ptr<QXmppDownload> QXmppFileSharingManager::downloadFile( }; fileShare.visitSources([&](const std::any &source) { - std::type_index index(source.type()); - try { - download->m_providerDownload = d->providers.at(index)->downloadFile(source, std::move(output), std::move(onProgress), std::move(onFinished)); + if (auto provider = providerForSource(source)) { + download->m_providerDownload = provider->downloadFile(source, std::move(output), std::move(onProgress), std::move(onFinished)); return true; - } catch (const std::out_of_range &) { - return false; } + return false; }); return download; @@ -329,4 +327,13 @@ void QXmppFileSharingManager::internalRegisterProvider(std::type_index index, st d->providers.insert_or_assign(index, provider); } +std::shared_ptr<QXmppFileSharingProvider> QXmppFileSharingManager::providerForSource(const std::any &source) const +{ + if (auto provider = d->providers.find(std::type_index(source.type())); + provider != d->providers.cend()) { + return provider->second; + } + return {}; +} + #include "QXmppFileSharingManager.moc" |
