mirror of
https://github.com/lux-tel/libsession-util.git
synced 2026-10-30 20:25:11 +00:00
63 lines
2.2 KiB
C
63 lines
2.2 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include "session/export.h"
|
|
#include "session/network/session_network_types.h"
|
|
#include "session/platform.h"
|
|
|
|
typedef struct open_group_server_parsed_download_url {
|
|
char base_url[268]; // null-terminated (max length 267), normalized (i.e. always lower-case,
|
|
// only has port if non-default, has trailing / removed)
|
|
char room[65]; // null-terminated (max length 64), normalized (always lower-case)
|
|
uint64_t file_id;
|
|
bool wants_stream_decryption;
|
|
} open_group_server_parsed_download_url;
|
|
|
|
/// API: session_open_group_server/session_open_group_server_parse_download_url
|
|
///
|
|
/// Parses a url to extract the information required to download the file.
|
|
///
|
|
/// Inputs:
|
|
/// - `url` -- [in] url to check.
|
|
/// - `out` -- [out] parsed download url.
|
|
///
|
|
/// Outputs:
|
|
/// - returns true if url was successfully parsed, false otherwise.
|
|
LIBSESSION_EXPORT bool session_open_group_server_parse_download_url(
|
|
const char* url, open_group_server_parsed_download_url* out);
|
|
|
|
/// API: session_open_group_server/session_open_group_server_generate_download_url
|
|
///
|
|
/// Determines whether a given download url requires deterministic decryption.
|
|
///
|
|
/// Inputs:
|
|
/// - `file_id` -- [in] id for the file generated by uploading to the open group server.
|
|
/// - `base_url` -- [in] the base url for the target open group server.
|
|
/// - `room` -- [in] the target room for the open group server.
|
|
/// - `pubkey_hex` -- [in] the pubkey for the target open group server (in hex).
|
|
/// - `use_stream_encryption` -- [in] flag indicating whether the file should use stream encryption.
|
|
/// - `out_url` -- [out] generated download url.
|
|
/// - `out_url_len` -- [in] size of the url buffer provided.
|
|
///
|
|
/// Outputs:
|
|
/// - returns true if url was successfully generated and copied into the buffer, false if otherwise
|
|
/// (including if the buffer was too small).
|
|
LIBSESSION_EXPORT bool session_open_group_server_generate_download_url(
|
|
uint64_t file_id,
|
|
const char* base_url,
|
|
const char* room,
|
|
const char* pubkey_hex,
|
|
bool use_stream_encryption,
|
|
char* out_url,
|
|
size_t out_url_len);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|