LeechCraft Azoth 0.6.70-18450-gabe19ee3b0
Modular multiprotocol IM plugin for LeechCraft
Loading...
Searching...
No Matches
itransfermanager.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <variant>
12#include <QObject>
13#include <QString>
14
15namespace LC::Azoth::Emitters
16{
17 class TransferJob;
18 class TransferManager;
19}
20
21namespace LC::Azoth
22{
23 namespace Transfers
24 {
25 enum class Phase : std::uint8_t
26 {
30 };
31
39
40 struct Error
41 {
43 QString Message_ {};
44
45 bool operator== (const Error&) const = default;
46 };
47 }
48
49 using TransferState = std::variant<
52 >;
53
54 inline bool IsTerminal (const TransferState& state)
55 {
56 return std::holds_alternative<Transfers::Error> (state) || state == TransferState { Transfers::Phase::Finished };
57 }
58
63 {
64 public:
65 virtual ~ITransferJob () = default;
66
67 virtual Emitters::TransferJob& GetTransferJobEmitter () = 0;
68
73 virtual void Abort () = 0;
74 };
75
76 class ITransferManager;
77
79 {
81 uint64_t JobId_;
82
83 QString EntryId_;
84
85 QString Name_;
86 qsizetype Size_;
87
88 QString Description_ {};
89
90 bool operator== (const IncomingOffer& other) const = default;
91 };
92
97 {
98 public:
99 virtual ~ITransferManager () = default;
100
101 virtual Emitters::TransferManager& GetTransferManagerEmitter () = 0;
102
116 virtual bool IsAvailable () const = 0;
117
118 virtual ITransferJob* Accept (const IncomingOffer& offer, const QString& savePath) = 0;
119
120 virtual void Decline (const IncomingOffer&) = 0;
121
148 virtual ITransferJob* SendFile (const QString& id,
149 const QString& variant,
150 const QString& path,
151 const QString& comment) = 0;
152 };
153}
154
155Q_DECLARE_INTERFACE (LC::Azoth::ITransferJob, "org.Deviant.LeechCraft.Azoth.ITransferJob/1.0")
156Q_DECLARE_INTERFACE (LC::Azoth::ITransferManager, "org.Deviant.LeechCraft.Azoth.ITransferManager/1.0")
This interface must be implemented by objects representing file transfer jobs.
virtual Emitters::TransferJob & GetTransferJobEmitter()=0
virtual void Abort()=0
Aborts a transfer.
virtual ~ITransferJob()=default
This interface must be implemented by transfer managers returned from IAccount::GetTransferManager().
virtual void Decline(const IncomingOffer &)=0
virtual ITransferJob * SendFile(const QString &id, const QString &variant, const QString &path, const QString &comment)=0
Requests a file transfer with the remote party.
virtual ~ITransferManager()=default
virtual Emitters::TransferManager & GetTransferManagerEmitter()=0
virtual bool IsAvailable() const =0
Returns whether the transfer manager is available.
virtual ITransferJob * Accept(const IncomingOffer &offer, const QString &savePath)=0
std::variant< Transfers::Phase, Transfers::Error > TransferState
bool IsTerminal(const TransferState &state)
bool operator==(const IncomingOffer &other) const =default
ITransferManager * Manager_
bool operator==(const Error &) const =default