From 78f97fe198286a120370f6c56921205191f986b0 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 10 Apr 2015 12:01:55 +0000 Subject: Tox: - switched to new api - updated tox core git-svn-id: http://svn.miranda-ng.org/main/trunk@12726 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/api_main.cpp | 134 ++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 67 deletions(-) (limited to 'protocols/Tox/src/api_main.cpp') diff --git a/protocols/Tox/src/api_main.cpp b/protocols/Tox/src/api_main.cpp index fc23165d44..19bb82f586 100644 --- a/protocols/Tox/src/api_main.cpp +++ b/protocols/Tox/src/api_main.cpp @@ -2,9 +2,19 @@ /* MAIN FUNCTIONS */ -Tox *tox_new(Tox_Options *options) +struct Tox_Options *tox_options_new(TOX_ERR_OPTIONS_NEW *error) { - return CreateFunction(__FUNCTION__)(options); + return CreateFunction(__FUNCTION__)(error); +} + +void tox_options_free(struct Tox_Options *options) +{ + CreateFunction(__FUNCTION__)(options); +} + +Tox *tox_new(const struct Tox_Options *options, const uint8_t *data, size_t length, TOX_ERR_NEW *error) +{ + return CreateFunction(__FUNCTION__)(options, data, length, error); } void tox_kill(Tox *tox) @@ -13,34 +23,34 @@ void tox_kill(Tox *tox) tox = NULL; } -void tox_get_address(const Tox *tox, uint8_t *address) +void tox_self_get_address(const Tox *tox, uint8_t *address) { CreateFunction(__FUNCTION__)(tox, address); } -int32_t tox_add_friend(Tox *tox,const uint8_t *address, const uint8_t *data, uint16_t length) +uint32_t tox_friend_add(Tox *tox, const uint8_t *address, const uint8_t *message, size_t length, TOX_ERR_FRIEND_ADD *error) { - return CreateFunction(__FUNCTION__)(tox, address, data, length); + return CreateFunction(__FUNCTION__)(tox, address, message, length, error); } -int32_t tox_add_friend_norequest(Tox *tox, const uint8_t *client_id) +uint32_t tox_friend_add_norequest(Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_ADD *error) { - return CreateFunction(__FUNCTION__)(tox, client_id); + return CreateFunction(__FUNCTION__)(tox, public_key, error); } -int32_t tox_get_friend_number(const Tox *tox, const uint8_t *client_id) +uint32_t tox_friend_by_public_key(const Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_BY_PUBLIC_KEY *error) { - return CreateFunction(__FUNCTION__)(tox, client_id); + return CreateFunction(__FUNCTION__)(tox, public_key, error); } -int tox_get_client_id(const Tox *tox, int32_t friendnumber, uint8_t *client_id) +bool tox_friend_get_public_key(const Tox *tox, uint32_t friend_number, uint8_t *public_key, TOX_ERR_FRIEND_GET_PUBLIC_KEY *error) { - return CreateFunction(__FUNCTION__)(tox, friendnumber, client_id); + return CreateFunction(__FUNCTION__)(tox, friend_number, public_key, error); } -int tox_del_friend(Tox *tox, int32_t friendnumber) +bool tox_friend_delete(Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_DELETE *error) { - return CreateFunction(__FUNCTION__)(tox, friendnumber); + return CreateFunction(__FUNCTION__)(tox, friend_number, error); } int tox_get_friend_connection_status(const Tox *tox, int32_t friendnumber) @@ -53,34 +63,29 @@ int tox_friend_exists(const Tox *tox, int32_t friendnumber) return CreateFunction(__FUNCTION__)(tox, friendnumber); } -uint32_t tox_send_message(Tox *tox, int32_t friendnumber, const uint8_t *message, uint32_t length) -{ - return CreateFunction(__FUNCTION__)(tox, friendnumber, message, length); -} - -uint32_t tox_send_action(Tox *tox, int32_t friendnumber, const uint8_t *action, uint32_t length) +uint32_t tox_friend_send_message(Tox *tox, uint32_t friend_number, TOX_MESSAGE_TYPE type, const uint8_t *message, size_t length, TOX_ERR_FRIEND_SEND_MESSAGE *error) { - return CreateFunction(__FUNCTION__)(tox, friendnumber, action, length); + return CreateFunction(__FUNCTION__)(tox, friend_number, type, message, length, error); } -int tox_set_name(Tox *tox, const uint8_t *name, uint16_t length) +bool tox_self_set_name(Tox *tox, const uint8_t *name, size_t length, TOX_ERR_SET_INFO *error) { - return CreateFunction(__FUNCTION__ )(tox, name, length); + return CreateFunction(__FUNCTION__)(tox, name, length, error); } -uint16_t tox_get_self_name(const Tox *tox, uint8_t *name) +void tox_self_get_name(const Tox *tox, uint8_t *name) { - return CreateFunction(__FUNCTION__)(tox, name); + CreateFunction(__FUNCTION__)(tox, name); } -int tox_get_name(const Tox *tox, int32_t friendnumber, uint8_t *name) +bool tox_friend_get_name(const Tox *tox, uint32_t friend_number, uint8_t *name, TOX_ERR_FRIEND_QUERY *error) { - return CreateFunction(__FUNCTION__)(tox, friendnumber, name); + return CreateFunction(__FUNCTION__)(tox, friend_number, name, error); } -int tox_get_name_size(const Tox *tox, int32_t friendnumber) +size_t tox_friend_get_name_size(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error) { - return CreateFunction(__FUNCTION__)(tox, friendnumber); + return CreateFunction(__FUNCTION__)(tox, friend_number, error); } int tox_get_self_name_size(const Tox *tox) @@ -88,14 +93,14 @@ int tox_get_self_name_size(const Tox *tox) return CreateFunction(__FUNCTION__)(tox); } -int tox_set_status_message(Tox *tox, const uint8_t *status, uint16_t length) +bool tox_self_set_status_message(Tox *tox, const uint8_t *status, size_t length, TOX_ERR_SET_INFO *error) { - return CreateFunction(__FUNCTION__)(tox, status, length); + return CreateFunction(__FUNCTION__)(tox, status, length, error); } -int tox_set_user_status(Tox *tox, uint8_t userstatus) +void tox_self_set_status(Tox *tox, TOX_USER_STATUS user_status) { - return CreateFunction(__FUNCTION__)(tox, userstatus); + CreateFunction(__FUNCTION__)(tox, user_status); } int tox_get_status_message_size(const Tox *tox, int32_t friendnumber) @@ -103,9 +108,9 @@ int tox_get_status_message_size(const Tox *tox, int32_t friendnumber) return CreateFunction(__FUNCTION__)(tox, friendnumber); } -int tox_get_self_status_message_size(const Tox *tox) +void tox_self_get_status_message(const Tox *tox, uint8_t *status) { - return CreateFunction(__FUNCTION__)(tox); + CreateFunction(__FUNCTION__)(tox, status); } int tox_get_status_message(const Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen) @@ -128,24 +133,24 @@ uint8_t tox_get_self_user_status(const Tox *tox) return CreateFunction(__FUNCTION__)(tox); } -uint64_t tox_get_last_online(const Tox *tox, int32_t friendnumber) +uint64_t tox_friend_get_last_online(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_GET_LAST_ONLINE *error) { - return CreateFunction(__FUNCTION__)(tox, friendnumber); + return CreateFunction(__FUNCTION__)(tox, friend_number, error); } -int tox_set_user_is_typing(Tox *tox, int32_t friendnumber, uint8_t is_typing) +int tox_friend_get_typing(Tox *tox, int32_t friendnumber, uint8_t is_typing) { return CreateFunction(__FUNCTION__)(tox, friendnumber, is_typing); } -uint8_t tox_get_is_typing(const Tox *tox, int32_t friendnumber) +bool tox_self_set_typing(Tox *tox, uint32_t friend_number, bool is_typing, TOX_ERR_SET_TYPING *error) { - return CreateFunction(__FUNCTION__)(tox, friendnumber); + return CreateFunction(__FUNCTION__)(tox, friend_number, is_typing, error); } -uint32_t tox_count_friendlist(const Tox *tox) +size_t tox_self_get_friend_list_size(const Tox *tox) { - return CreateFunction(__FUNCTION__)(tox); + return CreateFunction(__FUNCTION__)(tox); } uint32_t tox_get_num_online_friends(const Tox *tox) @@ -153,64 +158,59 @@ uint32_t tox_get_num_online_friends(const Tox *tox) return CreateFunction(__FUNCTION__)(tox); } -uint32_t tox_get_friendlist(const Tox *tox, int32_t *out_list, uint32_t list_size) +void tox_self_get_friend_list(const Tox *tox, uint32_t *list) { - return CreateFunction(__FUNCTION__)(tox, out_list, list_size); + CreateFunction(__FUNCTION__)(tox, list); } -void tox_callback_friend_request(Tox *tox, void(*function)(Tox *tox, const uint8_t *, const uint8_t *, uint16_t, void *), void *userdata) +void tox_callback_friend_request(Tox *tox, tox_friend_request_cb *function, void *user_data) { - CreateFunction(__FUNCTION__)(tox, function, userdata); + CreateFunction(__FUNCTION__)(tox, function, user_data); } -void tox_callback_friend_message(Tox *tox, void(*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *), void *userdata) +void tox_callback_friend_message(Tox *tox, tox_friend_message_cb *function, void *user_data) { - CreateFunction(__FUNCTION__)(tox, function, userdata); + CreateFunction(__FUNCTION__)(tox, function, user_data); } -void tox_callback_friend_action(Tox *tox, void(*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *), void *userdata) +void tox_callback_friend_name(Tox *tox, tox_friend_name_cb *function, void *user_data) { - CreateFunction(__FUNCTION__)(tox, function, userdata); + CreateFunction(__FUNCTION__)(tox, function, user_data); } -void tox_callback_name_change(Tox *tox, void(*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *), void *userdata) +void tox_callback_friend_status_message(Tox *tox, tox_friend_status_message_cb *function, void *user_data) { - CreateFunction(__FUNCTION__)(tox, function, userdata); + CreateFunction(__FUNCTION__)(tox, function, user_data); } -void tox_callback_status_message(Tox *tox, void(*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *), void *userdata) +void tox_callback_friend_status(Tox *tox, tox_friend_status_cb *function, void *user_data) { - CreateFunction(__FUNCTION__)(tox, function, userdata); + CreateFunction(__FUNCTION__)(tox, function, user_data); } -void tox_callback_user_status(Tox *tox, void(*function)(Tox *tox, int32_t, uint8_t, void *), void *userdata) +void tox_callback_friend_read_receipt(Tox *tox, tox_friend_read_receipt_cb *function, void *user_data) { - CreateFunction(__FUNCTION__)(tox, function, userdata); + CreateFunction(__FUNCTION__)(tox, function, user_data); } -void tox_callback_typing_change(Tox *tox, void(*function)(Tox *tox, int32_t, uint8_t, void *), void *userdata) +void tox_callback_friend_typing(Tox *tox, tox_friend_typing_cb *function, void *user_data) { - CreateFunction(__FUNCTION__)(tox, function, userdata); + CreateFunction(__FUNCTION__)(tox, function, user_data); } -void tox_callback_read_receipt(Tox *tox, void(*function)(Tox *tox, int32_t, uint32_t, void *), void *userdata) +void tox_callback_friend_connection_status(Tox *tox, tox_friend_connection_status_cb *function, void *user_data) { - CreateFunction(__FUNCTION__)(tox, function, userdata); -} - -void tox_callback_connection_status(Tox *tox, void(*function)(Tox *tox, int32_t, uint8_t, void *), void *userdata) -{ - CreateFunction(__FUNCTION__)(tox, function, userdata); + CreateFunction(__FUNCTION__)(tox, function, user_data); } /* SAVING AND LOADING FUNCTIONS */ -uint32_t tox_size(const Tox *tox) +size_t tox_get_savedata_size(const Tox *tox) { - return CreateFunction(__FUNCTION__)(tox); + return CreateFunction(__FUNCTION__)(tox); } -void tox_save(const Tox *tox, uint8_t *data) +void tox_get_savedata(const Tox *tox, uint8_t *data) { CreateFunction(__FUNCTION__)(tox, data); } -- cgit v1.2.3