#ifndef BAREV_H #define BAREV_H /* * barev.h - Pure C89 Barev client public API * Compatibility target: Pascal TBarevClient + barev_c_api exports. */ #include #ifdef __cplusplus extern "C" { #endif #define BAREV_VERSION "0.1" #define BAREV_DEFAULT_PORT 1337 typedef struct barev_client barev_client_t; typedef struct barev_buddy barev_buddy_t; typedef enum { BAREV_STATUS_OFFLINE = 0, BAREV_STATUS_AVAILABLE = 1, BAREV_STATUS_AWAY = 2, BAREV_STATUS_XA = 3, BAREV_STATUS_DND = 4 } barev_status_t; typedef enum { BAREV_CONN_DISCONNECTED = 0, BAREV_CONN_CONNECTING = 1, BAREV_CONN_STREAM_INIT = 2, BAREV_CONN_AUTHENTICATED = 3, BAREV_CONN_ONLINE = 4 } barev_conn_state_t; typedef void (*barev_log_cb)(const char *level, const char *msg, void *userdata); typedef void (*barev_typing_cb)(barev_buddy_t *buddy, int is_typing, void *userdata); typedef void (*barev_buddy_status_cb)(barev_buddy_t *buddy, int old_status, int new_status, void *userdata); typedef void (*barev_message_cb)(barev_buddy_t *buddy, const char *msg, void *userdata); typedef void (*barev_conn_state_cb)(barev_buddy_t *buddy, int state, void *userdata); typedef void (*barev_ft_offer_cb)(barev_buddy_t *buddy, const char *sid, const char *file_name, long file_size, void *userdata); typedef void (*barev_ft_progress_cb)(barev_buddy_t *buddy, const char *sid, long done, long total, void *userdata); typedef void (*barev_ft_complete_cb)(barev_buddy_t *buddy, const char *sid, const char *path, void *userdata); typedef void (*barev_ft_error_cb)(barev_buddy_t *buddy, const char *sid, const char *err, void *userdata); barev_client_t *barev_client_new(const char *nick, const char *my_ipv6, unsigned short port); void barev_client_free(barev_client_t *client); int barev_client_start(barev_client_t *client); void barev_client_stop(barev_client_t *client); void barev_client_process(barev_client_t *client); const char *barev_client_myjid(const barev_client_t *client); barev_buddy_t *barev_client_add_buddy(barev_client_t *client, const char *buddy_nick, const char *buddy_ipv6, unsigned short port); int barev_client_remove_buddy(barev_client_t *client, const char *buddy_jid); barev_buddy_t *barev_client_find_buddy(barev_client_t *client, const char *buddy_jid); int barev_client_connect(barev_client_t *client, const char *buddy_jid); int barev_client_send_message(barev_client_t *client, const char *buddy_jid, const char *msg); int barev_client_send_presence(barev_client_t *client, int status, const char *status_msg); int barev_client_send_typing(barev_client_t *client, const char *buddy_jid); int barev_client_send_paused(barev_client_t *client, const char *buddy_jid); int barev_client_send_file_offer(barev_client_t *client, const char *buddy_jid, const char *file_name, long file_size); int barev_client_accept_file_offer(barev_client_t *client, const char *sid); int barev_client_accept_file_offer_as(barev_client_t *client, const char *sid, const char *save_path); int barev_client_reject_file_offer(barev_client_t *client, const char *sid); void barev_set_userdata(barev_client_t *client, void *userdata); void barev_set_log_cb(barev_client_t *client, barev_log_cb cb); void barev_set_typing_cb(barev_client_t *client, barev_typing_cb cb); void barev_set_buddy_status_cb(barev_client_t *client, barev_buddy_status_cb cb); void barev_set_message_cb(barev_client_t *client, barev_message_cb cb); void barev_set_conn_state_cb(barev_client_t *client, barev_conn_state_cb cb); void barev_set_ft_offer_cb(barev_client_t *client, barev_ft_offer_cb cb); void barev_set_ft_progress_cb(barev_client_t *client, barev_ft_progress_cb cb); void barev_set_ft_complete_cb(barev_client_t *client, barev_ft_complete_cb cb); void barev_set_ft_error_cb(barev_client_t *client, barev_ft_error_cb cb); const char *barev_buddy_get_jid(const barev_buddy_t *buddy); const char *barev_buddy_get_nick(const barev_buddy_t *buddy); const char *barev_buddy_get_ipv6(const barev_buddy_t *buddy); unsigned short barev_buddy_get_port(const barev_buddy_t *buddy); int barev_buddy_get_status(const barev_buddy_t *buddy); const char *barev_buddy_get_status_message(const barev_buddy_t *buddy); #ifdef __cplusplus } #endif #endif