Ring Daemon
Loading...
Searching...
No Matches
datatransfer_interface.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2026 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef LIBJAMI_DATATRANSFERI_H
19#define LIBJAMI_DATATRANSFERI_H
20
21#include "def.h"
22
23#include "jami.h"
24
25#include <string>
26#include <map>
27#include <memory>
28
29namespace libjami {
30
31[[deprecated("Replaced by registerSignalHandlers")]] LIBJAMI_PUBLIC void registerDataXferHandlers(
32 const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
33
34using DataTransferId = uint64_t;
35
37 invalid = 0,
49};
50
51enum class LIBJAMI_PUBLIC DataTransferError : uint8_t {
52 success = 0,
56};
57
59enum class LIBJAMI_PUBLIC DataTransferFlags : uint8_t {
60 direction = 0,
61};
62
64{
65 std::string accountId;
66 DataTransferEventCode lastEvent {DataTransferEventCode::invalid};
67 uint32_t flags {0};
68 int64_t totalSize {0};
69 int64_t bytesProgress {0};
70 std::string author;
71 std::string peer;
72 std::string conversationId;
73 std::string displayName;
74 std::string path;
75 std::string mimetype;
77};
78
105
106LIBJAMI_PUBLIC void sendFile(const std::string& accountId,
107 const std::string& conversationId,
108 const std::string& path,
109 const std::string& displayName,
110 const std::string& replyTo) noexcept;
111
120LIBJAMI_PUBLIC bool downloadFile(const std::string& accountId,
121 const std::string& conversationId,
122 const std::string& interactionId,
123 const std::string& fileId,
124 const std::string& path) noexcept;
125
138DataTransferError cancelDataTransfer(const std::string& accountId,
139 const std::string& conversationId,
140 const std::string& fileId) noexcept LIBJAMI_PUBLIC;
141
151LIBJAMI_PUBLIC DataTransferError fileTransferInfo(const std::string& accountId,
152 const std::string& conversationId,
153 const std::string& fileId,
154 std::string& path,
155 int64_t& total,
156 int64_t& progress) noexcept;
157
158// Signals
160{
162 {
163 constexpr static const char* name = "DataTransferEvent";
164 using cb_type = void(const std::string& accountId,
165 const std::string& conversationId,
166 const std::string& interactionId,
167 const std::string& fileId,
168 int eventCode);
169 };
170};
171
172} // namespace libjami
173
174#endif // LIBJAMI_DATATRANSFERI_H
#define LIBJAMI_PUBLIC
Definition def.h:42
enum LIBJAMI_PUBLIC enum LIBJAMI_PUBLIC DataTransferError
DataTransferError cancelDataTransfer(const std::string &accountId, const std::string &conversationId, const std::string &fileId) noexcept
Refuse or abort an outgoing or an incoming file transfer.
enum LIBJAMI_PUBLIC wait_host_acceptance
enum LIBJAMI_PUBLIC finished
enum LIBJAMI_PUBLIC enum LIBJAMI_PUBLIC invalid_argument
DataTransferError fileTransferInfo(const std::string &accountId, const std::string &conversationId, const std::string &fileId, std::string &path, int64_t &total, int64_t &progress) noexcept
Return the amount of sent/received bytes of an existing data transfer.
enum LIBJAMI_PUBLIC unsupported
void sendFile(const std::string &accountId, const std::string &conversationId, const std::string &path, const std::string &displayName, const std::string &replyTo) noexcept
Asynchronously send a file to a peer using given account connection.
bool downloadFile(const std::string &accountId, const std::string &conversationId, const std::string &interactionId, const std::string &fileId, const std::string &path) noexcept
Asks for retransferring a file.
enum LIBJAMI_PUBLIC created
enum LIBJAMI_PUBLIC wait_peer_acceptance
enum LIBJAMI_PUBLIC closed_by_host
enum LIBJAMI_PUBLIC closed_by_peer
enum LIBJAMI_PUBLIC enum LIBJAMI_PUBLIC io
enum LIBJAMI_PUBLIC unjoinable_peer
enum LIBJAMI_PUBLIC timeout_expired
void registerDataXferHandlers(const std::map< std::string, std::shared_ptr< CallbackWrapperBase > > &handlers)
enum LIBJAMI_PUBLIC enum LIBJAMI_PUBLIC unknown
enum LIBJAMI_PUBLIC enum LIBJAMI_PUBLIC enum LIBJAMI_PUBLIC DataTransferFlags
Bit definition for DataTransferInfo.flags field.
enum LIBJAMI_PUBLIC ongoing
enum LIBJAMI_PUBLIC DataTransferEventCode
uint64_t DataTransferId
enum LIBJAMI_PUBLIC invalid_pathname
std::string accountId
Identifier of the emiter/receiver account.
std::string mimetype
MimeType of transferred data (https://www.iana.org/assignments/media-types/media-types....
std::string peer
Identifier of the remote peer (in the semantic of the associated account)
std::string displayName
Human oriented transfer name.
std::string path
associated local file path if supported (empty, if not)
void(const std::string &accountId, const std::string &conversationId, const std::string &interactionId, const std::string &fileId, int eventCode) cb_type