/**
* \file snikket.h the Snikket SDK for C
*
* Everything returned from an SDK procedure or passed to a function
* pointer, both strings and opaque types, must be passed to
* snikket_release when you are done with it.
*/
#ifndef __SNIKKET_H
#define __SNIKKET_H
#ifndef MKDOCS
#include <stdbool.h>
#include <stddef.h>
#ifndef API_PREFIX
#ifdef _WIN32
#define API_PREFIX __declspec(dllimport)
#else
#define API_PREFIX
#endif
#endif
#endif
typedef void (*snikket_panic_callback) (const char *info);
enum
#ifdef __clang__
__attribute__((enum_extensibility(closed)))
#endif
snikket_message_type {
MessageChat = 0,
MessageCall = 1,
MessageChannel = 2,
MessageChannelPrivate = 3
};
enum
#ifdef __clang__
__attribute__((enum_extensibility(closed)))
#endif
snikket_message_direction {
MessageReceived = 0,
MessageSent = 1
};
enum
#ifdef __clang__
__attribute__((enum_extensibility(closed)))
#endif
snikket_message_status {
MessagePending = 0,
MessageDeliveredToServer = 1,
MessageDeliveredToDevice = 2,
MessageFailedToSend = 3
};
enum
#ifdef __clang__
__attribute__((enum_extensibility(closed)))
#endif
snikket_ui_state {
Pinned = 0,
Open = 1,
Closed = 2
};
enum
#ifdef __clang__
__attribute__((enum_extensibility(closed)))
#endif
snikket_jingle_call_status {
NoCall = 0,
Incoming = 1,
Outgoing = 2,
Connecting = 3,
Ongoing = 4,
Failed = 5
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* Initializes the SDK
*
* This must be first before calling SDK functions (otherwise those calls will hang waiting for a response).
*
* @param panicCallback a callback to execute if the SDK panics. The SDK will continue processing events after a panic and you may want to stop it after receiving this callback. Use `NULL` for no callback
* @returns `NULL` if the thread initializes successfully or a null-terminated C string if an error occurs during initialization
*/
API_PREFIX const char *snikket_setup(snikket_panic_callback panic_callback);
/**
* Stops the SDK, blocking until the main thread has completed. Once ended, it cannot be restarted (this is because static variable state will be retained from the last run).
*
* It can be safely called any number of times – if the SDK is not running this function will just return.
*
* After executing no more calls to SDK functions can be made (as these will hang waiting for a response).
*
* Thread-safety: Can be called safely called on any thread.
*
* @param wait If `true`, this function will wait for all events scheduled to execute in the future on the SDK thread to complete. If `false`, immediate pending events will be finished and the SDK stopped without executing events scheduled in the future
*/
API_PREFIX void snikket_stop(bool wait);
/**
* Informs the garbage collector that object is no longer needed by the C code.
*
* If the object has no remaining reference the garbage collector can free the associated memory (which can happen at any time in the future). It does not free the memory immediately.
*
* Thread-safety: can be called on any thread.
*
* @param ptr a handle to an arbitrary SDK object returned from an SDK function
*/
API_PREFIX void snikket_release(const void *ptr);
API_PREFIX void *snikket_persistence_media_store_f_s_new(const char *path);
API_PREFIX void snikket_persistence_media_store_f_s_get_media_path(void *media_store_fs, const char *uri, void (*callback) (const char*, void*), void *callback__context);
/**
* Create a basic persistence layer based on sqlite
*
* @param dbfile path to sqlite database
* @params media a MediaStore to use for media
* @returns new persistence layer
*/
API_PREFIX void *snikket_persistence_sqlite_new(const char *dbfile, void *media);
API_PREFIX void snikket_persistence_sqlite_get_message(void *sqlite, const char *accountId, const char *chatId, const char *serverId, const char *localId, void (*callback) (void*, void*), void *callback__context);
API_PREFIX void snikket_persistence_sqlite_remove_account(void *sqlite, const char *accountId, bool completely);
API_PREFIX void snikket_persistence_sqlite_list_accounts(void *sqlite, void (*callback) (const char**, size_t, void*), void *callback__context);
/**
* The ID as set by the creator of this message
*/
API_PREFIX const char *snikket_chat_message_local_id(void *chat_message);
/**
* The ID as set by the authoritative server
*/
API_PREFIX const char *snikket_chat_message_server_id(void *chat_message);
/**
* The ID of the server which set the serverId
*/
API_PREFIX const char *snikket_chat_message_server_id_by(void *chat_message);
/**
* The type of this message (Chat, Call, etc)
*/
API_PREFIX enum snikket_message_type snikket_chat_message_type(void *chat_message);
/**
* The timestamp of this message, in format YYYY-MM-DDThh:mm:ss[.sss]Z
*/
API_PREFIX const char *snikket_chat_message_timestamp(void *chat_message);
/**
* The ID of the sender of this message
*/
API_PREFIX const char *snikket_chat_message_sender_id(void *chat_message);
/**
* Message this one is in reply to, or NULL
*/
API_PREFIX void *snikket_chat_message_reply_to_message(void *chat_message);
/**
* ID of the thread this message is in, or NULL
*/
API_PREFIX const char *snikket_chat_message_thread_id(void *chat_message);
/**
* Array of attachments to this message
*/
API_PREFIX size_t snikket_chat_message_attachments(void *chat_message, void ***outPtr);
/**
* List of reactions to this message
*/
API_PREFIX size_t snikket_chat_message_reaction_keys(void *chat_message, const char ***outPtr);
/**
* Details of a set of reaction to this message
*/
API_PREFIX size_t snikket_chat_message_reaction_details(void *chat_message, const char *reactionKey, void ***outPtr);
/**
* Body text of this message or NULL
*/
API_PREFIX const char *snikket_chat_message_text(void *chat_message);
/**
* Language code for the body text
*/
API_PREFIX const char *snikket_chat_message_lang(void *chat_message);
/**
* Direction of this message
*/
API_PREFIX enum snikket_message_direction snikket_chat_message_direction(void *chat_message);
/**
* Status of this message
*/
API_PREFIX enum snikket_message_status snikket_chat_message_status(void *chat_message);
/**
* Status of this message
*/
API_PREFIX void snikket_chat_message_set_status(void *chat_message, enum snikket_message_status value);
/**
* Array of past versions of this message, if it has been edited
*/
API_PREFIX size_t snikket_chat_message_versions(void *chat_message, void ***outPtr);
/**
* Create a new ChatMessage in reply to this one
*/
API_PREFIX void *snikket_chat_message_reply(void *chat_message);
API_PREFIX const char *snikket_chat_message_get_reply_id(void *chat_message);
/**
* Get HTML version of the message body
*
* WARNING: this is possibly untrusted HTML. You must parse or sanitize appropriately!
*/
API_PREFIX const char *snikket_chat_message_html(void *chat_message);
/**
* The ID of the Chat this message is associated with
*/
API_PREFIX const char *snikket_chat_message_chat_id(void *chat_message);
/**
* The ID of the account associated with this message
*/
API_PREFIX const char *snikket_chat_message_account(void *chat_message);
/**
* Is this an incoming message?
*/
API_PREFIX bool snikket_chat_message_is_incoming(void *chat_message);
/**
* The URI of an icon for the thread associated with this message, or NULL
*/
API_PREFIX const char *snikket_chat_message_thread_icon(void *chat_message);
/**
* The last status of the call if this message is related to a call
*/
API_PREFIX const char *snikket_chat_message_call_status(void *chat_message);
/**
* The session id of the call if this message is related to a call
*/
API_PREFIX const char *snikket_chat_message_call_sid(void *chat_message);
/**
* The duration of the call if this message is related to a call
*/
API_PREFIX const char *snikket_chat_message_call_duration(void *chat_message);
API_PREFIX void *snikket_chat_attachment_create(const char *name, const char *mime, int size, const char *uri);
API_PREFIX const char *snikket_chat_attachment_name(void *chat_attachment);
API_PREFIX const char *snikket_chat_attachment_mime(void *chat_attachment);
API_PREFIX int snikket_chat_attachment_size(void *chat_attachment);
API_PREFIX size_t snikket_chat_attachment_uris(void *chat_attachment, const char ***outPtr);
API_PREFIX size_t snikket_chat_attachment_hashes(void *chat_attachment, void ***outPtr);
API_PREFIX void *snikket_hash_from_hex(const char *algorithm, const char *hash);
API_PREFIX void *snikket_hash_from_uri(const char *uri);
API_PREFIX const char *snikket_hash_algorithm(void *hash);
API_PREFIX const char *snikket_hash_to_uri(void *hash);
API_PREFIX const char *snikket_hash_to_hex(void *hash);
API_PREFIX const char *snikket_hash_to_base_64(void *hash);
API_PREFIX const char *snikket_hash_to_base_64_url(void *hash);
API_PREFIX const char *snikket_reaction_sender_id(void *reaction);
API_PREFIX const char *snikket_reaction_timestamp(void *reaction);
API_PREFIX const char *snikket_reaction_text(void *reaction);
API_PREFIX const char *snikket_reaction_key(void *reaction);
API_PREFIX const char *snikket_reaction_envelope_id(void *reaction);
/**
* @returns a new blank ChatMessageBuilder
*/
API_PREFIX void *snikket_chat_message_builder_new();
/**
* The ID as set by the creator of this message
*/
API_PREFIX const char *snikket_chat_message_builder_local_id(void *chat_message_builder);
/**
* The ID as set by the creator of this message
*/
API_PREFIX void snikket_chat_message_builder_set_local_id(void *chat_message_builder, const char *value);
/**
* The ID as set by the authoritative server
*/
API_PREFIX const char *snikket_chat_message_builder_server_id(void *chat_message_builder);
/**
* The ID as set by the authoritative server
*/
API_PREFIX void snikket_chat_message_builder_set_server_id(void *chat_message_builder, const char *value);
/**
* The ID of the server which set the serverId
*/
API_PREFIX const char *snikket_chat_message_builder_server_id_by(void *chat_message_builder);
/**
* The ID of the server which set the serverId
*/
API_PREFIX void snikket_chat_message_builder_set_server_id_by(void *chat_message_builder, const char *value);
/**
* The type of this message (Chat, Call, etc)
*/
API_PREFIX enum snikket_message_type snikket_chat_message_builder_type(void *chat_message_builder);
/**
* The type of this message (Chat, Call, etc)
*/
API_PREFIX void snikket_chat_message_builder_set_type(void *chat_message_builder, enum snikket_message_type value);
/**
* The timestamp of this message, in format YYYY-MM-DDThh:mm:ss[.sss]+00:00
*/
API_PREFIX const char *snikket_chat_message_builder_timestamp(void *chat_message_builder);
/**
* The timestamp of this message, in format YYYY-MM-DDThh:mm:ss[.sss]+00:00
*/
API_PREFIX void snikket_chat_message_builder_set_timestamp(void *chat_message_builder, const char *value);
API_PREFIX const char *snikket_chat_message_builder_sender_id(void *chat_message_builder);
API_PREFIX void snikket_chat_message_builder_set_sender_id(void *chat_message_builder, const char *value);
/**
* Message this one is in reply to, or NULL
*/
API_PREFIX void *snikket_chat_message_builder_reply_to_message(void *chat_message_builder);
/**
* Message this one is in reply to, or NULL
*/
API_PREFIX void snikket_chat_message_builder_set_reply_to_message(void *chat_message_builder, void *value);
/**
* ID of the thread this message is in, or NULL
*/
API_PREFIX const char *snikket_chat_message_builder_thread_id(void *chat_message_builder);
/**
* ID of the thread this message is in, or NULL
*/
API_PREFIX void snikket_chat_message_builder_set_thread_id(void *chat_message_builder, const char *value);
/**
* Array of attachments to this message
*/
API_PREFIX size_t snikket_chat_message_builder_attachments(void *chat_message_builder, void ***outPtr);
/**
* Body text of this message or NULL
*/
API_PREFIX const char *snikket_chat_message_builder_text(void *chat_message_builder);
/**
* Body text of this message or NULL
*/
API_PREFIX void snikket_chat_message_builder_set_text(void *chat_message_builder, const char *value);
/**
* Language code for the body text
*/
API_PREFIX const char *snikket_chat_message_builder_lang(void *chat_message_builder);
/**
* Language code for the body text
*/
API_PREFIX void snikket_chat_message_builder_set_lang(void *chat_message_builder, const char *value);
/**
* Direction of this message
*/
API_PREFIX enum snikket_message_direction snikket_chat_message_builder_direction(void *chat_message_builder);
/**
* Direction of this message
*/
API_PREFIX void snikket_chat_message_builder_set_direction(void *chat_message_builder, enum snikket_message_direction value);
/**
* Status of this message
*/
API_PREFIX enum snikket_message_status snikket_chat_message_builder_status(void *chat_message_builder);
/**
* Status of this message
*/
API_PREFIX void snikket_chat_message_builder_set_status(void *chat_message_builder, enum snikket_message_status value);
/**
* Array of past versions of this message, if it has been edited
*/
API_PREFIX void snikket_chat_message_builder_set_versions(void *chat_message_builder, void *const *inPtr, size_t count);
/**
* Array of past versions of this message, if it has been edited
*/
API_PREFIX size_t snikket_chat_message_builder_versions(void *chat_message_builder, void ***outPtr);
API_PREFIX void snikket_chat_message_builder_add_attachment(void *chat_message_builder, void *attachment);
/**
* Set rich text using an HTML string
* Also sets the plain text body appropriately
*/
API_PREFIX void snikket_chat_message_builder_set_html(void *chat_message_builder, const char *html);
/**
* The ID of the Chat this message is associated with
*/
API_PREFIX const char *snikket_chat_message_builder_chat_id(void *chat_message_builder);
/**
* The ID of the sender of this message
*/
API_PREFIX const char *snikket_chat_message_builder_get_sender_id(void *chat_message_builder);
API_PREFIX bool snikket_chat_message_builder_is_incoming(void *chat_message_builder);
API_PREFIX void *snikket_chat_message_builder_build(void *chat_message_builder);
/**
* Create a basic persistence layer that persists nothing
*
* @returns new persistence layer
*/
API_PREFIX void *snikket_persistence_dummy_new();
API_PREFIX void *snikket_push_receive(const char *data, void *persistence);
API_PREFIX const char *snikket_notification_title(void *notification);
API_PREFIX const char *snikket_notification_body(void *notification);
API_PREFIX const char *snikket_notification_account_id(void *notification);
API_PREFIX const char *snikket_notification_chat_id(void *notification);
API_PREFIX const char *snikket_notification_sender_id(void *notification);
API_PREFIX const char *snikket_notification_message_id(void *notification);
API_PREFIX enum snikket_message_type snikket_notification_type(void *notification);
API_PREFIX const char *snikket_notification_call_status(void *notification);
API_PREFIX const char *snikket_notification_call_sid(void *notification);
API_PREFIX const char *snikket_notification_image_uri(void *notification);
API_PREFIX const char *snikket_notification_lang(void *notification);
API_PREFIX const char *snikket_notification_timestamp(void *notification);
/**
* Create a new Client to connect to a particular account
*
* @param address the account to connect to
* @param persistence the persistence layer to use for storage
*/
API_PREFIX void *snikket_client_new(const char *address, void *persistence);
/**
* Set to false to suppress sending available presence
*/
API_PREFIX void snikket_client_set_send_available(void *client, bool value);
/**
* Start this client running and trying to connect to the server
*/
API_PREFIX void snikket_client_start(void *client);
/**
* Gets the client ready to use but does not connect to the server
*/
API_PREFIX void snikket_client_start_offline(void *client, void (*ready) (void*), void *ready__context);
/**
* Destroy local data for this account
*
* @param completely if true chats, messages, etc will be deleted as well
*/
API_PREFIX void snikket_client_logout(void *client, bool completely);
/**
* Sets the password to be used in response to the password needed event
*
* @param password
*/
API_PREFIX void snikket_client_use_password(void *client, const char *password);
/**
* Get the account ID for this Client
*
* @returns account id
*/
API_PREFIX const char *snikket_client_account_id(void *client);
/**
* Get the current display name for this account
*
* @returns display name
*/
API_PREFIX const char *snikket_client_display_name(void *client);
/**
* Set the current display name for this account on the server
*
* @param display name to set (ignored if empty or NULL)
*/
API_PREFIX void snikket_client_set_display_name(void *client, const char *displayName);
/**
* Turn a file into a ChatAttachment for attaching to a ChatMessage
*/
API_PREFIX void snikket_client_prepare_attachment(void *client, void *source, void (*callback) (void*, void*), void *callback__context);
/**
* @returns array of open chats, sorted by last activity
*/
API_PREFIX size_t snikket_client_get_chats(void *client, void ***outPtr);
/**
* Search for chats the user can start or join
*
* @param q the search query to use
* @param callback takes two arguments, the query that was used and the array of results
*/
API_PREFIX void snikket_client_find_available_chats(void *client, const char *q, void (*callback) (const char*, void**, size_t, void*), void *callback__context);
/**
* Start or join a chat from the search results
*
* @returns the chat that was started
*/
API_PREFIX void *snikket_client_start_chat(void *client, void *availableChat);
/**
* Find a chat by id
*
* @returns the chat if known, or NULL
*/
API_PREFIX void *snikket_client_get_chat(void *client, const char *chatId);
/**
* Enable push notifications
*
* @param push_service the address of a push proxy
* @param vapid_private_pkcs8 the private key for signing JWT of the push service
* @param endpoint the final target for the push proxy to forward to
* @param p256dh A P-256 uncompressed point in ANSI X9.62 format
* @param auth Random 16 octed value
* @param grace Grace period during which not to generate push if another app is active for same account, in seconds (negative for none)
* @param claims Optional additional JWT claims as key then value
*/
API_PREFIX void snikket_client_enable_push(void *client, const char *push_service, const char *endpoint, const unsigned char *p256dh, size_t p256dh__len, const unsigned char *auth, size_t auth__len, int grace, const unsigned char *vapid_private_pkcs8, size_t vapid_private_pkcs8__len, const char *const *claims, size_t claims__len);
/**
* Event fired when client needs a password for authentication
*
* @param handler takes one argument, the Client that needs a password
*/
API_PREFIX void snikket_client_add_password_needed_listener(void *client, void (*handler) (void*, void*), void *handler__context);
/**
* Event fired when client is connected and fully synchronized
*
* @param handler takes no arguments
*/
API_PREFIX void snikket_client_add_status_online_listener(void *client, void (*handler) (void*), void *handler__context);
/**
* Event fired when client is disconnected
*
* @param handler takes no arguments
*/
API_PREFIX void snikket_client_add_status_offline_listener(void *client, void (*handler) (void*), void *handler__context);
/**
* Event fired when connection fails with a fatal error and will not be retried
*
* @param handler takes no arguments
*/
API_PREFIX void snikket_client_add_connection_failed_listener(void *client, void (*handler) (void*), void *handler__context);
/**
* Event fired when TLS checks fail, to give client the chance to override
*
* @param handler takes two arguments, the PEM of the cert and an array of DNS names, and must return true to accept or false to reject
*/
API_PREFIX void snikket_client_add_tls_check_listener(void *client, bool (*handler) (const char*, const char**, size_t, void*), void *handler__context);
/**
* Event fired when a new ChatMessage comes in on any Chat
* Also fires when status of a ChatMessage changes,
* when a ChatMessage is edited, or when a reaction is added
*
* @param handler takes two arguments, the ChatMessage and ChatMessageEvent enum describing what happened
*/
API_PREFIX void snikket_client_add_chat_message_listener(void *client, void (*handler) (void*, int, void*), void *handler__context);
/**
* Event fired when syncing a new ChatMessage that was send when offline.
* Normally you don't want this, but it may be useful if you want to notify on app start.
*
* @param handler takes one argument, the ChatMessage
*/
API_PREFIX void snikket_client_add_sync_message_listener(void *client, void (*handler) (void*, void*), void *handler__context);
/**
* Event fired when a Chat's metadata is updated, or when a new Chat is added
*
* @param handler takes one argument, an array of Chats that were updated
*/
API_PREFIX void snikket_client_add_chats_updated_listener(void *client, void (*handler) (void**, size_t, void*), void *handler__context);
/**
* Event fired when a new call comes in
*
* @param handler takes one argument, the call Session
*/
API_PREFIX void snikket_client_add_call_ring_listener(void *client, void (*handler) (void*, void*), void *handler__context);
/**
* Event fired when a call is retracted or hung up
*
* @param handler takes two arguments, the associated Chat ID and Session ID
*/
API_PREFIX void snikket_client_add_call_retract_listener(void *client, void (*handler) (const char*, const char*, void*), void *handler__context);
/**
* Event fired when an outgoing call starts ringing
*
* @param handler takes two arguments, the associated Chat ID and Session ID
*/
API_PREFIX void snikket_client_add_call_ringing_listener(void *client, void (*handler) (const char*, const char*, void*), void *handler__context);
/**
* Event fired when an existing call changes status (connecting, failed, etc)
*
* @param handler takes one argument, the associated Session
*/
API_PREFIX void snikket_client_add_call_update_status_listener(void *client, void (*handler) (void*, void*), void *handler__context);
/**
* Event fired when a call is asking for media to send
*
* @param handler takes three arguments, the call Session,
* a boolean indicating if audio is desired,
* and a boolean indicating if video is desired
*/
API_PREFIX void snikket_client_add_call_media_listener(void *client, void (*handler) (void*, bool, bool, void*), void *handler__context);
/**
* Event fired when call has a new MediaStreamTrack to play
*
* @param handler takes three arguments, the associated Chat ID,
* the new MediaStreamTrack, and an array of any associated MediaStreams
*/
API_PREFIX void snikket_client_add_call_track_listener(void *client, void (*handler) (const char*, void*, void**, size_t, void*), void *handler__context);
/**
* Let the SDK know the UI is in the foreground
*/
API_PREFIX void snikket_client_set_in_foreground(void *client);
/**
* Let the SDK know the UI is in the foreground
*/
API_PREFIX void snikket_client_set_not_in_foreground(void *client);
/**
* ID of this Chat
*/
API_PREFIX const char *snikket_chat_chat_id(void *chat);
/**
* Current state of this chat
*/
API_PREFIX enum snikket_ui_state snikket_chat_ui_state(void *chat);
API_PREFIX bool snikket_chat_is_blocked(void *chat);
/**
* Fetch a page of messages before some point
*
* @param beforeId id of the message to look before
* @param beforeTime timestamp of the message to look before,
* String in format YYYY-MM-DDThh:mm:ss[.sss]+00:00
* @param handler takes one argument, an array of ChatMessage that are found
*/
API_PREFIX void snikket_chat_get_messages_before(void *chat, const char *beforeId, const char *beforeTime, void (*handler) (void**, size_t, void*), void *handler__context);
/**
* Fetch a page of messages after some point
*
* @param afterId id of the message to look after
* @param afterTime timestamp of the message to look after,
* String in format YYYY-MM-DDThh:mm:ss[.sss]+00:00
* @param handler takes one argument, an array of ChatMessage that are found
*/
API_PREFIX void snikket_chat_get_messages_after(void *chat, const char *afterId, const char *afterTime, void (*handler) (void**, size_t, void*), void *handler__context);
/**
* Fetch a page of messages around (before, including, and after) some point
*
* @param aroundId id of the message to look around
* @param aroundTime timestamp of the message to look around,
* String in format YYYY-MM-DDThh:mm:ss[.sss]+00:00
* @param handler takes one argument, an array of ChatMessage that are found
*/
API_PREFIX void snikket_chat_get_messages_around(void *chat, const char *aroundId, const char *aroundTime, void (*handler) (void**, size_t, void*), void *handler__context);
/**
* Send a ChatMessage to this Chat
*
* @param message the ChatMessage to send
*/
API_PREFIX void snikket_chat_send_message(void *chat, void *message);
/**
* Signals that all messages up to and including this one have probably
* been displayed to the user
*
* @param message the ChatMessage most recently displayed
*/
API_PREFIX void snikket_chat_mark_read_up_to(void *chat, void *message);
/**
* Save this Chat on the server
*/
API_PREFIX void snikket_chat_bookmark(void *chat);
/**
* Get the list of IDs of participants in this Chat
*
* @returns array of IDs
*/
API_PREFIX size_t snikket_chat_get_participants(void *chat, const char ***outPtr);
/**
* Get the details for one participant in this Chat
*
* @param participantId the ID of the participant to look up
*/
API_PREFIX void *snikket_chat_get_participant_details(void *chat, const char *participantId);
/**
* Correct an already-send message by replacing it with a new one
*
* @param localId the localId of the message to correct
* must be the localId of the first version ever sent, not a subsequent correction
* @param message the new ChatMessage to replace it with
*/
API_PREFIX void snikket_chat_correct_message(void *chat, const char *localId, void *message);
/**
* Add new reaction to a message in this Chat
*
* @param m ChatMessage to react to
* @param reaction emoji of the reaction
*/
API_PREFIX void snikket_chat_add_reaction(void *chat, void *m, void *reaction);
/**
* Remove an already-sent reaction from a message
*
* @param m ChatMessage to remove the reaction from
* @param reaction the emoji to remove
*/
API_PREFIX void snikket_chat_remove_reaction(void *chat, void *m, void *reaction);
/**
* Call this whenever the user is typing, can call on every keystroke
*
* @param threadId optional, what thread the user has selected if any
* @param content optional, what the user has typed so far
*/
API_PREFIX void snikket_chat_typing(void *chat, const char *threadId, const char *content);
/**
* Call this whenever the user makes a chat or thread "active" in your UX
* If you call this with true you MUST later call it will false
*
* @param active true if the chat is "active", false otherwise
* @param threadId optional, what thread the user has selected if any
*/
API_PREFIX void snikket_chat_set_active(void *chat, bool active, const char *threadId);
/**
* Archive this chat
*/
API_PREFIX void snikket_chat_close(void *chat);
/**
* Pin or unpin this chat
*/
API_PREFIX void snikket_chat_toggle_pinned(void *chat);
/**
* Block this chat so it will not re-open
*/
API_PREFIX void snikket_chat_block(void *chat, void *reportSpam, bool onServer);
/**
* Unblock this chat so it will open again
*/
API_PREFIX void snikket_chat_unblock(void *chat, bool onServer);
/**
* Update notification preferences
*/
API_PREFIX void snikket_chat_set_notifications(void *chat, bool filtered, bool mention, bool reply);
/**
* Should notifications be filtered?
*/
API_PREFIX bool snikket_chat_notifications_filtered(void *chat);
/**
* Should a mention produce a notification?
*/
API_PREFIX bool snikket_chat_notify_mention(void *chat);
/**
* Should a reply produce a notification?
*/
API_PREFIX bool snikket_chat_notify_reply(void *chat);
/**
* An ID of the most recent message in this chat
*/
API_PREFIX const char *snikket_chat_last_message_id(void *chat);
/**
* The timestamp of the most recent message in this chat
*/
API_PREFIX const char *snikket_chat_last_message_timestamp(void *chat);
/**
* Get the URI image to represent this Chat, or null
*/
API_PREFIX const char *snikket_chat_get_photo(void *chat);
/**
* Get the URI to a placeholder image to represent this Chat
*/
API_PREFIX const char *snikket_chat_get_placeholder(void *chat);
/**
* An ID of the last message displayed to the user
*/
API_PREFIX const char *snikket_chat_read_up_to(void *chat);
/**
* The number of message that have not yet been displayed to the user
*/
API_PREFIX int snikket_chat_unread_count(void *chat);
/**
* A preview of the chat, such as the most recent message body
*/
API_PREFIX const char *snikket_chat_preview(void *chat);
API_PREFIX void snikket_chat_set_display_name(void *chat, const char *fn);
/**
* The display name of this Chat
*/
API_PREFIX const char *snikket_chat_get_display_name(void *chat);
API_PREFIX void snikket_chat_set_trusted(void *chat, bool trusted);
/**
* Is this a chat with an entity we trust to see our online status?
*/
API_PREFIX bool snikket_chat_is_trusted(void *chat);
API_PREFIX bool snikket_chat_syncing(void *chat);
/**
* Can audio calls be started in this Chat?
*/
API_PREFIX bool snikket_chat_can_audio_call(void *chat);
/**
* Can video calls be started in this Chat?
*/
API_PREFIX bool snikket_chat_can_video_call(void *chat);
/**
* Start a new call in this Chat
*
* @param audio do we want audio in this call
* @param video do we want video in this call
*/
API_PREFIX void snikket_chat_start_call(void *chat, bool audio, bool video);
/**
* Accept any incoming calls in this Chat
*/
API_PREFIX void snikket_chat_accept_call(void *chat);
/**
* Hangup or reject any calls in this chat
*/
API_PREFIX void snikket_chat_hangup(void *chat);
/**
* The current status of a call in this chat
*/
API_PREFIX enum snikket_jingle_call_status snikket_chat_call_status(void *chat);
/**
* A DTMFSender for a call in this chat, or NULL
*/
API_PREFIX void *snikket_chat_dtmf(void *chat);
/**
* All video tracks in all active calls in this chat
*/
API_PREFIX size_t snikket_chat_video_tracks(void *chat, void ***outPtr);
API_PREFIX const char *snikket_jingle_media_stream_track_id(void *media_stream_track);
API_PREFIX bool snikket_jingle_media_stream_track_muted(void *media_stream_track);
API_PREFIX const char *snikket_jingle_media_stream_track_kind(void *media_stream_track);
API_PREFIX size_t snikket_jingle_media_stream_track_supported_audio_formats(void *media_stream_track, void ***outPtr);
/**
* Event fired for new inbound audio frame
*
* @param callback takes three arguments, the Signed 16-bit PCM data, the clock rate, and the number of channels
*/
API_PREFIX void snikket_jingle_media_stream_track_add_pcm_listener(void *media_stream_track, void (*callback) (short*, size_t, int, int, void*), void *callback__context);
/**
* Event fired when ready for next outbound audio frame
*
* @param callback
*/
API_PREFIX void snikket_jingle_media_stream_track_add_ready_for_pcm_listener(void *media_stream_track, void (*callback) (void*), void *callback__context);
/**
* Send new audio to this track
*
* @param pcm 16-bit signed linear PCM data (interleaved)
* @param clockRate the sampling rate of the data
* @param channels the number of audio channels
*/
API_PREFIX void snikket_jingle_media_stream_track_write_pcm(void *media_stream_track, const short *pcm, size_t pcm__len, int clockRate, int channels);
API_PREFIX void snikket_jingle_media_stream_track_stop(void *media_stream_track);
API_PREFIX void *snikket_jingle_audio_format_new(const char *format, unsigned char payloadType, int clockRate, int channels);
API_PREFIX int snikket_jingle_audio_format_clock_rate(void *audio_format);
API_PREFIX int snikket_jingle_audio_format_channels(void *audio_format);
/**
* The ID of the Chat this search result represents
*/
API_PREFIX const char *snikket_available_chat_chat_id(void *available_chat);
/**
* The display name of this search result
*/
API_PREFIX const char *snikket_available_chat_display_name(void *available_chat);
/**
* A human-readable note associated with this search result
*/
API_PREFIX const char *snikket_available_chat_note(void *available_chat);
/**
* Is this search result a channel?
*/
API_PREFIX bool snikket_available_chat_is_channel(void *available_chat);
API_PREFIX const char *snikket_jingle_initiated_session_sid(void *initiated_session);
API_PREFIX const char *snikket_jingle_initiated_session_chat_id(void *initiated_session);
API_PREFIX void snikket_jingle_initiated_session_accept(void *initiated_session);
API_PREFIX void snikket_jingle_initiated_session_hangup(void *initiated_session);
API_PREFIX void snikket_jingle_initiated_session_add_media(void *initiated_session, void *const *streams, size_t streams__len);
API_PREFIX enum snikket_jingle_call_status snikket_jingle_initiated_session_call_status(void *initiated_session);
API_PREFIX size_t snikket_jingle_initiated_session_video_tracks(void *initiated_session, void ***outPtr);
API_PREFIX void *snikket_jingle_initiated_session_dtmf(void *initiated_session);
API_PREFIX void snikket_jingle_initiated_session_supply_media(void *initiated_session, void *const *streams, size_t streams__len);
API_PREFIX void *snikket_jingle_media_stream_new();
/**
* Create default bidirectional audio track
*/
API_PREFIX void *snikket_jingle_media_stream_make_audio();
API_PREFIX void snikket_jingle_media_stream_add_track(void *media_stream, void *track);
API_PREFIX size_t snikket_jingle_media_stream_get_tracks(void *media_stream, void ***outPtr);
API_PREFIX const char *snikket_participant_display_name(void *participant);
API_PREFIX const char *snikket_participant_photo_uri(void *participant);
API_PREFIX const char *snikket_participant_placeholder_uri(void *participant);
API_PREFIX bool snikket_participant_is_self(void *participant);
API_PREFIX void *snikket_attachment_source_new(const char *path, const char *mime);
API_PREFIX const char *snikket_attachment_source_path(void *attachment_source);
API_PREFIX const char *snikket_attachment_source_type(void *attachment_source);
API_PREFIX const char *snikket_attachment_source_name(void *attachment_source);
API_PREFIX int snikket_attachment_source_size(void *attachment_source);
API_PREFIX bool snikket_channel_is_private(void *channel);
API_PREFIX const char *snikket_custom_emoji_reaction_uri(void *custom_emoji_reaction);
API_PREFIX const char *snikket_identicon_svg(const char *source);
/**
* Produce /.well-known/ni/ paths instead of ni:/// URIs
* for referencing media by hash.
*
* This can be useful eg for intercepting with a Service Worker.
*/
API_PREFIX bool snikket_config_relative_hash_uri();
/**
* Produce /.well-known/ni/ paths instead of ni:/// URIs
* for referencing media by hash.
*
* This can be useful eg for intercepting with a Service Worker.
*/
API_PREFIX void snikket_config_set_relative_hash_uri(bool value);
/**
* Trades off some performance for lower / more consistent memory usage
*/
API_PREFIX void snikket_config_enable_constrained_memory_mode();
/**
* Schedule DTMF events to be sent
*
* @param tones can be any number of 0123456789#*ABCD,
*/
API_PREFIX void snikket_jingle_dtmf_sender_insert_dtmf(void *dtmf_sender, const char *tones);
#ifdef __cplusplus
}
#endif
#undef API_PREFIX
#endif