File transfer manager class Handles efficient chunked file transfers with resume capability. More...
#include <file_transfer.h>
Public Member Functions | |
| FileTransferManager (RatsClient &client, const FileTransferConfig &config=FileTransferConfig()) | |
| Constructor. | |
| ~FileTransferManager () | |
| Destructor. | |
| void | set_config (const FileTransferConfig &config) |
| Update transfer configuration. | |
| const FileTransferConfig & | get_config () const |
| Get current configuration. | |
| bool | handle_binary_data (const std::string &peer_id, const std::vector< uint8_t > &binary_data) |
| Handle binary data that might be file transfer chunks. | |
| void | set_progress_callback (FileTransferProgressCallback callback) |
| Set progress callback for transfer updates. | |
| void | set_completion_callback (FileTransferCompletedCallback callback) |
| Set completion callback for transfer completion. | |
| void | set_request_callback (FileTransferRequestCallback callback) |
| Set incoming transfer request callback. | |
| void | set_directory_progress_callback (DirectoryTransferProgressCallback callback) |
| Set directory transfer progress callback. | |
| void | set_file_request_callback (FileRequestCallback callback) |
| Set file request callback (called when receiving file requests) | |
| void | set_directory_request_callback (DirectoryRequestCallback callback) |
| Set directory request callback (called when receiving directory requests) | |
| std::string | send_file (const std::string &peer_id, const std::string &file_path, const std::string &remote_filename="") |
| Send a file to a peer. | |
| std::string | send_file_with_metadata (const std::string &peer_id, const std::string &file_path, const FileMetadata &metadata) |
| Send a file with custom metadata. | |
| std::string | send_directory (const std::string &peer_id, const std::string &directory_path, const std::string &remote_directory_name="", bool recursive=true) |
| Send an entire directory to a peer. | |
| std::string | request_file (const std::string &peer_id, const std::string &remote_file_path, const std::string &local_path) |
| Request a file from a remote peer. | |
| std::string | request_directory (const std::string &peer_id, const std::string &remote_directory_path, const std::string &local_directory_path, bool recursive=true) |
| Request a directory from a remote peer. | |
| bool | accept_file_transfer (const std::string &transfer_id, const std::string &local_path) |
| Accept an incoming file transfer. | |
| bool | reject_file_transfer (const std::string &transfer_id, const std::string &reason="") |
| Reject an incoming file transfer. | |
| bool | accept_directory_transfer (const std::string &transfer_id, const std::string &local_path) |
| Accept an incoming directory transfer. | |
| bool | reject_directory_transfer (const std::string &transfer_id, const std::string &reason="") |
| Reject an incoming directory transfer. | |
| bool | pause_transfer (const std::string &transfer_id) |
| Pause an active transfer. | |
| bool | resume_transfer (const std::string &transfer_id) |
| Resume a paused transfer. | |
| bool | cancel_transfer (const std::string &transfer_id) |
| Cancel an active or paused transfer. | |
| bool | retry_transfer (const std::string &transfer_id) |
| Retry a failed transfer. | |
| std::shared_ptr< FileTransferProgress > | get_transfer_progress (const std::string &transfer_id) const |
| Get progress information for a transfer. | |
| std::vector< std::shared_ptr< FileTransferProgress > > | get_active_transfers () const |
| Get all active transfers. | |
| std::vector< std::shared_ptr< FileTransferProgress > > | get_transfer_history (size_t limit=0) const |
| Get transfer history. | |
| void | clear_transfer_history () |
| Clear transfer history. | |
| nlohmann::json | get_transfer_statistics () const |
| Get statistics about transfers. | |
Static Public Member Functions | |
| static std::string | calculate_file_checksum (const std::string &file_path, const std::string &algorithm="sha256") |
| Calculate file checksum. | |
| static FileMetadata | get_file_metadata (const std::string &file_path) |
| Get file metadata. | |
| static DirectoryMetadata | get_directory_metadata (const std::string &directory_path, bool recursive=true) |
| Get directory metadata. | |
| static bool | validate_file_path (const std::string &file_path, bool check_write=false) |
| Validate file path and permissions. | |
File transfer manager class Handles efficient chunked file transfers with resume capability.
Definition at line 185 of file file_transfer.h.
| librats::FileTransferManager::FileTransferManager | ( | RatsClient & | client, |
| const FileTransferConfig & | config = FileTransferConfig() |
||
| ) |
Constructor.
| client | Reference to RatsClient for communication |
| config | Transfer configuration settings |
| librats::FileTransferManager::~FileTransferManager | ( | ) |
Destructor.
| bool librats::FileTransferManager::accept_directory_transfer | ( | const std::string & | transfer_id, |
| const std::string & | local_path | ||
| ) |
Accept an incoming directory transfer.
| transfer_id | Transfer identifier from request |
| local_path | Local path where directory should be saved |
| bool librats::FileTransferManager::accept_file_transfer | ( | const std::string & | transfer_id, |
| const std::string & | local_path | ||
| ) |
Accept an incoming file transfer.
| transfer_id | Transfer identifier from request |
| local_path | Local path where file should be saved |
|
static |
Calculate file checksum.
| file_path | Path to file |
| algorithm | Hash algorithm ("md5", "sha256") |
| bool librats::FileTransferManager::cancel_transfer | ( | const std::string & | transfer_id | ) |
Cancel an active or paused transfer.
| transfer_id | Transfer to cancel |
| void librats::FileTransferManager::clear_transfer_history | ( | ) |
Clear transfer history.
| std::vector< std::shared_ptr< FileTransferProgress > > librats::FileTransferManager::get_active_transfers | ( | ) | const |
Get all active transfers.
| const FileTransferConfig & librats::FileTransferManager::get_config | ( | ) | const |
Get current configuration.
|
static |
Get directory metadata.
| directory_path | Path to directory |
| recursive | Whether to scan recursively |
|
static |
Get file metadata.
| file_path | Path to file |
| std::vector< std::shared_ptr< FileTransferProgress > > librats::FileTransferManager::get_transfer_history | ( | size_t | limit = 0 | ) | const |
Get transfer history.
| limit | Maximum number of entries to return (0 for all) |
| std::shared_ptr< FileTransferProgress > librats::FileTransferManager::get_transfer_progress | ( | const std::string & | transfer_id | ) | const |
Get progress information for a transfer.
| transfer_id | Transfer to query |
| nlohmann::json librats::FileTransferManager::get_transfer_statistics | ( | ) | const |
Get statistics about transfers.
| bool librats::FileTransferManager::handle_binary_data | ( | const std::string & | peer_id, |
| const std::vector< uint8_t > & | binary_data | ||
| ) |
Handle binary data that might be file transfer chunks.
| peer_id | Source peer ID |
| binary_data | Binary data received |
| bool librats::FileTransferManager::pause_transfer | ( | const std::string & | transfer_id | ) |
Pause an active transfer.
| transfer_id | Transfer to pause |
| bool librats::FileTransferManager::reject_directory_transfer | ( | const std::string & | transfer_id, |
| const std::string & | reason = "" |
||
| ) |
Reject an incoming directory transfer.
| transfer_id | Transfer identifier from request |
| reason | Optional reason for rejection |
| bool librats::FileTransferManager::reject_file_transfer | ( | const std::string & | transfer_id, |
| const std::string & | reason = "" |
||
| ) |
Reject an incoming file transfer.
| transfer_id | Transfer identifier from request |
| reason | Optional reason for rejection |
| std::string librats::FileTransferManager::request_directory | ( | const std::string & | peer_id, |
| const std::string & | remote_directory_path, | ||
| const std::string & | local_directory_path, | ||
| bool | recursive = true |
||
| ) |
Request a directory from a remote peer.
| peer_id | Target peer ID |
| remote_directory_path | Path to directory on remote peer |
| local_directory_path | Local path where directory should be saved |
| recursive | Whether to include subdirectories (default: true) |
| std::string librats::FileTransferManager::request_file | ( | const std::string & | peer_id, |
| const std::string & | remote_file_path, | ||
| const std::string & | local_path | ||
| ) |
Request a file from a remote peer.
| peer_id | Target peer ID |
| remote_file_path | Path to file on remote peer |
| local_path | Local path where file should be saved |
| bool librats::FileTransferManager::resume_transfer | ( | const std::string & | transfer_id | ) |
Resume a paused transfer.
| transfer_id | Transfer to resume |
| bool librats::FileTransferManager::retry_transfer | ( | const std::string & | transfer_id | ) |
Retry a failed transfer.
| transfer_id | Transfer to retry |
| std::string librats::FileTransferManager::send_directory | ( | const std::string & | peer_id, |
| const std::string & | directory_path, | ||
| const std::string & | remote_directory_name = "", |
||
| bool | recursive = true |
||
| ) |
Send an entire directory to a peer.
| peer_id | Target peer ID |
| directory_path | Local directory path to send |
| remote_directory_name | Optional remote directory name |
| recursive | Whether to include subdirectories (default: true) |
| std::string librats::FileTransferManager::send_file | ( | const std::string & | peer_id, |
| const std::string & | file_path, | ||
| const std::string & | remote_filename = "" |
||
| ) |
Send a file to a peer.
| peer_id | Target peer ID |
| file_path | Local file path to send |
| remote_filename | Optional remote filename (default: use local name) |
| std::string librats::FileTransferManager::send_file_with_metadata | ( | const std::string & | peer_id, |
| const std::string & | file_path, | ||
| const FileMetadata & | metadata | ||
| ) |
Send a file with custom metadata.
| peer_id | Target peer ID |
| file_path | Local file path to send |
| metadata | Custom file metadata |
| void librats::FileTransferManager::set_completion_callback | ( | FileTransferCompletedCallback | callback | ) |
Set completion callback for transfer completion.
| callback | Function to call when transfers complete |
| void librats::FileTransferManager::set_config | ( | const FileTransferConfig & | config | ) |
Update transfer configuration.
| config | New configuration settings |
| void librats::FileTransferManager::set_directory_progress_callback | ( | DirectoryTransferProgressCallback | callback | ) |
Set directory transfer progress callback.
| callback | Function to call with directory transfer progress |
| void librats::FileTransferManager::set_directory_request_callback | ( | DirectoryRequestCallback | callback | ) |
Set directory request callback (called when receiving directory requests)
| callback | Function to call when receiving directory requests |
| void librats::FileTransferManager::set_file_request_callback | ( | FileRequestCallback | callback | ) |
Set file request callback (called when receiving file requests)
| callback | Function to call when receiving file requests |
| void librats::FileTransferManager::set_progress_callback | ( | FileTransferProgressCallback | callback | ) |
Set progress callback for transfer updates.
| callback | Function to call with progress updates |
| void librats::FileTransferManager::set_request_callback | ( | FileTransferRequestCallback | callback | ) |
Set incoming transfer request callback.
| callback | Function to call when receiving transfer requests |
|
static |
Validate file path and permissions.
| file_path | Path to validate |
| check_write | Whether to check write permissions |