diff options
Diffstat (limited to 'libs/libaxolotl/src/session_record.h')
-rw-r--r-- | libs/libaxolotl/src/session_record.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libs/libaxolotl/src/session_record.h b/libs/libaxolotl/src/session_record.h new file mode 100644 index 0000000000..99f113d2eb --- /dev/null +++ b/libs/libaxolotl/src/session_record.h @@ -0,0 +1,50 @@ +#ifndef SESSION_RECORD_H +#define SESSION_RECORD_H + +#include <stdint.h> +#include <stddef.h> +#include "axolotl_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int session_record_create(session_record **record, session_state *state, axolotl_context *global_context); +int session_record_serialize(axolotl_buffer **buffer, const session_record *record); +int session_record_deserialize(session_record **record, const uint8_t *data, size_t len, axolotl_context *global_context); +int session_record_copy(session_record **record, session_record *other_record, axolotl_context *global_context); + +int session_record_has_session_state(session_record *record, uint32_t version, const ec_public_key *alice_base_key); +session_state *session_record_get_state(session_record *record); +void session_record_set_state(session_record *record, session_state *state); + +session_record_state_node *session_record_get_previous_states_head(const session_record *record); +session_state *session_record_get_previous_states_element(const session_record_state_node *node); +session_record_state_node *session_record_get_previous_states_next(const session_record_state_node *node); + +/** + * Removes the specified node in the previous states list. + * @param node the node to remove + * @return the node immediately following the removed node, or null if at the end of the list + */ +session_record_state_node *session_record_get_previous_states_remove(session_record *record, session_record_state_node *node); + +int session_record_is_fresh(session_record *record); + +/** + * Move the current session_state into the list of "previous" session states, + * and replace the current session_state with a fresh reset instance. + * + * @return 0 on success, negative on failure + */ +int session_record_archive_current_state(session_record *record); + +int session_record_promote_state(session_record *record, session_state *promoted_state); + +void session_record_destroy(axolotl_type_base *type); + +#ifdef __cplusplus +} +#endif + +#endif /* SESSION_RECORD_H */ |