Delete local conversations atomically, retain replay protection and sequence counters, and guard asynchronous media work by history generation. Add Android avatar menu and confirmation, persistent file cleanup, and regression coverage. Fix unnamed member wire padding and compact Android member action spacing. Validation: 158 core tests passed; targeted DM tests, desktop build, Android unit tests and debug APK build passed.
69 lines
3.6 KiB
C
69 lines
3.6 KiB
C
/* dm_media — файлы личных бесед и ограниченное ciphertext-хранилище M.
|
|
* Шифрование/проверка/публикация файлов в media_async; БД и сеть в uasync.
|
|
* dm_core вызывает track внутри своей транзакции. Квитанция файла независима
|
|
* от квитанции сообщения; создаётся после проверки, публикации и commit.
|
|
* Суперузлом и заданиями удаления владеет dm_mailbox_media.
|
|
*/
|
|
#ifndef DM_MEDIA_H
|
|
#define DM_MEDIA_H
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include "../media_async/attachment.h"
|
|
|
|
struct UTUN_INSTANCE;
|
|
|
|
#define DM_MEDIA_DESC_SIZE 56 /* UUID:16, plaintext_size:8, SHA256(ciphertext):32 */
|
|
#define DM_MEDIA_RECEIPT_SIZE 152
|
|
#define DM_MEDIA_MAX_SIZE (1024ULL * 1024 * 1024)
|
|
|
|
#define DM_MEDIA_OFFER 1
|
|
#define DM_MEDIA_STORE 2
|
|
#define DM_MEDIA_STORED 3
|
|
#define DM_MEDIA_RECEIPT 4
|
|
#define DM_MEDIA_DELETE 5
|
|
#define DM_MEDIA_DELETE_ACK 6
|
|
#define DM_MEDIA_EXPIRED 7
|
|
#define DM_MEDIA_REJECT 8
|
|
|
|
int dm_media_init(struct UTUN_INSTANCE* inst);
|
|
/* quiesce до media_async_destroy; destroy после workers, до групп/core/mailbox. */
|
|
void dm_media_quiesce(struct UTUN_INSTANCE* inst);
|
|
void dm_media_destroy(struct UTUN_INSTANCE* inst);
|
|
|
|
/* Подготовить копию и enqueue file-сообщение асинхронно. 0=задача принята. */
|
|
int dm_send_file(struct UTUN_INSTANCE* inst, const char* conv, const char* path, const struct attachment_info* info,
|
|
int remove_source);
|
|
struct dm_file_req {
|
|
struct UTUN_INSTANCE* inst;
|
|
char conv[64];
|
|
uint64_t generation;
|
|
char path[1024];
|
|
struct attachment_info info;
|
|
int remove_source; /* Только принадлежащий приложению временный файл. */
|
|
};
|
|
void dm_send_file_trampoline(void* arg);
|
|
|
|
/* Внутри транзакции dm_core, 0=записано/точный повтор. Для text — пустая операция. */
|
|
int dm_media_track(struct UTUN_INSTANCE* inst, int dir, const uint8_t* msg, size_t len);
|
|
const uint8_t* dm_message_media(const uint8_t* msg, size_t len);
|
|
uint64_t dm_media_cipher_size(uint64_t plain_size);
|
|
int dm_media_verify_receipt(struct UTUN_INSTANCE* inst, const uint8_t* receipt, const uint8_t* msg, size_t len);
|
|
int dm_media_accept_receipt(struct UTUN_INSTANCE* inst, const uint8_t* receipt);
|
|
|
|
/* Удаление: prepare внутри транзакции, committed после commit (callbacks отмены синхронны). */
|
|
int dm_media_forget_prepare(struct UTUN_INSTANCE* inst, const char* conv, uint64_t generation);
|
|
void dm_media_forget_committed(struct UTUN_INSTANCE* inst, const char* conv);
|
|
/* Владение путями worker: hold до запуска, release после завершения. Уборка ждёт busy=0. */
|
|
int dm_media_file_hold(struct UTUN_INSTANCE* inst, const char* conv, uint64_t generation, const char* path);
|
|
void dm_media_file_release(struct UTUN_INSTANCE* inst, const char* path);
|
|
|
|
/* Общие операции control для endpoint/M и mailbox/S. Все пакеты подписаны. */
|
|
int dm_media_send(struct UTUN_INSTANCE* inst, uint64_t group, uint64_t peer,
|
|
uint8_t cmd, const uint8_t* body, size_t len);
|
|
int dm_media_scope(struct UTUN_INSTANCE* inst, uint64_t group, uint64_t node,
|
|
const char* role, uint64_t author, uint64_t recipient);
|
|
void dm_media_notify(struct UTUN_INSTANCE* inst, uint64_t conv);
|
|
|
|
#endif
|