From 37d97288306faefa193c1f6347665c8f58da6534 Mon Sep 17 00:00:00 2001 From: Jman012 Date: Mon, 18 Nov 2013 20:05:35 -0800 Subject: Added functions tox_count_chatlist and tox_copy_chatlist. These functions are akin to the tox_count_friendlist and tox_copy_friendlist, made available on the public API. --- toxcore/tox.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'toxcore/tox.c') diff --git a/toxcore/tox.c b/toxcore/tox.c index 6a0c6a62..26ab3429 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -477,6 +477,25 @@ int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t return group_message_send(m, groupnumber, message, length); } +/* Return the number of chats in the instance m. + * You should use this to determine how much memory to allocate + * for copy_friendlist. */ +uint32_t tox_count_chatlist(Tox *tox) +{ + Messenger *m = tox; + return count_chatlist(m); +} + +/* Copy a list of valid chat IDs into the array out_list. + * If out_list is NULL, returns 0. + * Otherwise, returns the number of elements copied. + * If the array was too small, the contents + * of out_list will be truncated to list_size. */ +uint32_t tox_copy_chatlist(Tox *tox, int *out_list, uint32_t list_size) +{ + Messenger *m = tox; + return copy_chatlist(m, out_list, list_size); +} /****************FILE SENDING FUNCTIONS*****************/ -- cgit v1.2.3 From 21e514572cb2f93b141f60a2876e083c651f4f39 Mon Sep 17 00:00:00 2001 From: Jman012 Date: Mon, 18 Nov 2013 20:10:07 -0800 Subject: Fixed a few typos. --- toxcore/Messenger.c | 4 ++-- toxcore/Messenger.h | 2 +- toxcore/tox.c | 2 +- toxcore/tox.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'toxcore/tox.c') diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 43572eff..14f01373 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -2175,9 +2175,9 @@ int get_friendlist(Messenger *m, int **out_list, uint32_t *out_list_length) return 0; } -/* Return the number of chat in the instance m. +/* Return the number of chats in the instance m. * You should use this to determine how much memory to allocate - * for copy_grouplist. */ + * for copy_chatlist. */ uint32_t count_chatlist(Messenger *m) { uint32_t ret = 0; diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 1e463e36..3b99b3cf 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -635,7 +635,7 @@ int get_friendlist(Messenger *m, int **out_list, uint32_t *out_list_length); /* Return the number of chats in the instance m. * You should use this to determine how much memory to allocate - * for copy_grouplist. */ + * for copy_chatlist. */ uint32_t count_chatlist(Messenger *m); /* Copy a list of valid chat IDs into the array out_list. diff --git a/toxcore/tox.c b/toxcore/tox.c index 26ab3429..5e110cbe 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -479,7 +479,7 @@ int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t /* Return the number of chats in the instance m. * You should use this to determine how much memory to allocate - * for copy_friendlist. */ + * for copy_chatlist. */ uint32_t tox_count_chatlist(Tox *tox) { Messenger *m = tox; diff --git a/toxcore/tox.h b/toxcore/tox.h index 497fa3bc..97fb912a 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -407,7 +407,7 @@ int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t /* Return the number of chats in the instance m. * You should use this to determine how much memory to allocate - * for copy_friendlist. */ + * for copy_chatlist. */ uint32_t tox_count_chatlist(Tox *tox); /* Copy a list of valid chat IDs into the array out_list. -- cgit v1.2.3 From d2b56faded6e88e916d8f291c1cdff82f5cdd1ff Mon Sep 17 00:00:00 2001 From: irungentoo Date: Fri, 22 Nov 2013 23:31:55 -0500 Subject: Added function to get the number of peers and list of names for group chats. --- testing/nTox.c | 14 +++++++++++++- toxcore/Messenger.c | 53 ++++++++++++++++++++++++++++++++++++++++++++------- toxcore/Messenger.h | 15 +++++++++++++++ toxcore/group_chats.c | 13 +++++++++++++ toxcore/group_chats.h | 12 ++++++++++++ toxcore/tox.c | 23 ++++++++++++++++++++++ toxcore/tox.h | 18 +++++++++++++++-- 7 files changed, 138 insertions(+), 10 deletions(-) (limited to 'toxcore/tox.c') diff --git a/testing/nTox.c b/testing/nTox.c index d9206415..7448bf7e 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -974,13 +974,25 @@ void print_invite(Tox *m, int friendnumber, uint8_t *group_public_key, void *use tox_join_groupchat(m, friendnumber, group_public_key)); new_lines(msg); } +void print_groupchatpeers(Tox *m, int groupnumber) +{ + char msg[256]; + int num = tox_group_number_peers(m, groupnumber); + if (num == -1) + return; + uint8_t names[num][TOX_MAX_NAME_LENGTH]; + tox_group_copy_names(m, groupnumber, names, num); + uint32_t i; + for (i = 0; i < num; ++i) + new_lines(names[i]); +} void print_groupmessage(Tox *m, int groupnumber, int peernumber, uint8_t *message, uint16_t length, void *userdata) { char msg[256 + length]; uint8_t name[TOX_MAX_NAME_LENGTH]; int len = tox_group_peername(m, groupnumber, peernumber, name); - + //print_groupchatpeers(m, groupnumber); if (len <= 0) name[0] = 0; diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 8f6c42f9..889de367 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -707,6 +707,23 @@ int write_cryptpacket_id(Messenger *m, int friendnumber, uint8_t packet_id, uint /**********GROUP CHATS************/ +/* return 1 if the groupnumber is not valid. + * return 0 if the groupnumber is valid. + */ +static uint8_t groupnumber_not_valid(Messenger *m, int groupnumber) +{ + if ((unsigned int)groupnumber >= m->numchats) + return 1; + + if (m->chats == NULL) + return 1; + + if (m->chats[groupnumber] == NULL) + return 1; + return 0; +} + + /* returns valid ip port of connected friend on success * returns zeroed out IP_Port on failure */ @@ -964,6 +981,7 @@ int join_groupchat(Messenger *m, int friendnumber, uint8_t *friend_group_public_ return -1; } + /* send a group message * return 0 on success * return -1 on failure @@ -971,13 +989,7 @@ int join_groupchat(Messenger *m, int friendnumber, uint8_t *friend_group_public_ int group_message_send(Messenger *m, int groupnumber, uint8_t *message, uint32_t length) { - if ((unsigned int)groupnumber >= m->numchats) - return -1; - - if (m->chats == NULL) - return -1; - - if (m->chats[groupnumber] == NULL) + if (groupnumber_not_valid(m, groupnumber)) return -1; if (group_sendmessage(m->chats[groupnumber], message, length) > 0) @@ -986,6 +998,33 @@ int group_message_send(Messenger *m, int groupnumber, uint8_t *message, uint32_t return -1; } +/* Return the number of peers in the group chat on success. + * return -1 on failure + */ +int group_number_peers(Messenger *m, int groupnumber) +{ + if (groupnumber_not_valid(m, groupnumber)) + return -1; + + return group_numpeers(m->chats[groupnumber]); +} + +/* List all the peers in the group chat. + * + * Copies the names of the peers to the name[length][MAX_NICK_BYTES] array. + * + * returns the number of peers on success. + * + * return -1 on failure. + */ +int group_names(Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES], uint16_t length) +{ + if (groupnumber_not_valid(m, groupnumber)) + return -1; + + return group_client_names(m->chats[groupnumber], names, length); +} + static int handle_group(void *object, IP_Port source, uint8_t *packet, uint32_t length) { Messenger *m = object; diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 3b99b3cf..651f3f12 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -497,6 +497,21 @@ int join_groupchat(Messenger *m, int friendnumber, uint8_t *friend_group_public_ int group_message_send(Messenger *m, int groupnumber, uint8_t *message, uint32_t length); +/* Return the number of peers in the group chat on success. + * return -1 on failure + */ +int group_number_peers(Messenger *m, int groupnumber); + +/* List all the peers in the group chat. + * + * Copies the names of the peers to the name[length][MAX_NICK_BYTES] array. + * + * returns the number of peers on success. + * + * return -1 on failure. + */ +int group_names(Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES], uint16_t length); + /****************FILE SENDING*****************/ diff --git a/toxcore/group_chats.c b/toxcore/group_chats.c index 7f28bf9b..34c84c40 100644 --- a/toxcore/group_chats.c +++ b/toxcore/group_chats.c @@ -616,6 +616,19 @@ void callback_groupmessage(Group_Chat *chat, void (*function)(Group_Chat *chat, chat->group_message_userdata = userdata; } +uint32_t group_numpeers(Group_Chat *chat) +{ + return chat->numpeers; +} + +uint32_t group_client_names(Group_Chat *chat, uint8_t names[][MAX_NICK_BYTES], uint16_t length) +{ + uint32_t i; + for (i = 0; i < chat->numpeers && i < length; ++i) { + group_peername(chat, i, names[i]); + } + return i; +} Group_Chat *new_groupchat(Networking_Core *net) { diff --git a/toxcore/group_chats.h b/toxcore/group_chats.h index 859b5658..4257b1f5 100644 --- a/toxcore/group_chats.h +++ b/toxcore/group_chats.h @@ -128,6 +128,18 @@ uint32_t group_newpeer(Group_Chat *chat, uint8_t *client_id); Group_Chat *new_groupchat(Networking_Core *net); +/* Return the number of peers in the group chat. + */ +uint32_t group_numpeers(Group_Chat *chat); + +/* List all the peers in the group chat. + * + * Copies the names of the peers to the name[length][MAX_NICK_BYTES] array. + * + * returns the number of peers. + */ +uint32_t group_client_names(Group_Chat *chat, uint8_t names[][MAX_NICK_BYTES], uint16_t length); + /* Kill a group chat * * Frees the memory and everything. diff --git a/toxcore/tox.c b/toxcore/tox.c index 5e110cbe..b5e754bb 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -477,6 +477,29 @@ int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t return group_message_send(m, groupnumber, message, length); } +/* Return the number of peers in the group chat on success. + * return -1 on failure + */ +int tox_group_number_peers(Tox *tox, int groupnumber) +{ + Messenger *m = tox; + return group_number_peers(m, groupnumber); +} + +/* List all the peers in the group chat. + * + * Copies the names of the peers to the name[length][MAX_NICK_BYTES] array. + * + * returns the number of peers on success. + * + * return -1 on failure. + */ +int tox_group_copy_names(Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t length) +{ + Messenger *m = tox; + return group_names(m, groupnumber, names, length); +} + /* Return the number of chats in the instance m. * You should use this to determine how much memory to allocate * for copy_chatlist. */ diff --git a/toxcore/tox.h b/toxcore/tox.h index 97fb912a..a0093ff3 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -398,13 +398,27 @@ int tox_invite_friend(Tox *tox, int friendnumber, int groupnumber); */ int tox_join_groupchat(Tox *tox, int friendnumber, uint8_t *friend_group_public_key); - /* send a group message * return 0 on success * return -1 on failure */ int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t length); - + +/* Return the number of peers in the group chat on success. + * return -1 on failure + */ +int tox_group_number_peers(Tox *tox, int groupnumber); + +/* List all the peers in the group chat. + * + * Copies the names of the peers to the name[length][TOX_MAX_NAME_LENGTH] array. + * + * returns the number of peers on success. + * + * return -1 on failure. + */ +int tox_group_copy_names(Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t length); + /* Return the number of chats in the instance m. * You should use this to determine how much memory to allocate * for copy_chatlist. */ -- cgit v1.2.3 From f21a9a7666e0f93cd8c19d1491c92526424ae0cb Mon Sep 17 00:00:00 2001 From: irungentoo Date: Sat, 23 Nov 2013 17:19:02 -0500 Subject: Added callback that tells you when the peer name list of a group chat changes. --- testing/nTox.c | 9 ++++++++- toxcore/Messenger.c | 41 +++++++++++++++++++++++++++++++++++++---- toxcore/Messenger.h | 9 +++++++++ toxcore/group_chats.c | 15 +++++++++++++++ toxcore/group_chats.h | 11 ++++++++++- toxcore/tox.c | 13 +++++++++++++ toxcore/tox.h | 8 ++++++++ 7 files changed, 100 insertions(+), 6 deletions(-) (limited to 'toxcore/tox.c') diff --git a/testing/nTox.c b/testing/nTox.c index 7448bf7e..e7216d33 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -1003,7 +1003,13 @@ void print_groupmessage(Tox *m, int groupnumber, int peernumber, uint8_t *messag new_lines(msg); } - +void print_groupnamelistchange(Tox *m, int groupnumber, void *userdata) +{ + char msg[256]; + sprintf(msg, "[g] %u: Name list changed:", groupnumber); + new_lines(msg); + print_groupchatpeers(m, groupnumber); +} void file_request_accept(Tox *m, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) { @@ -1105,6 +1111,7 @@ int main(int argc, char *argv[]) tox_callback_file_data(m, write_file, NULL); tox_callback_file_control(m, file_print_control, NULL); tox_callback_file_sendrequest(m, file_request_accept, NULL); + tox_callback_group_namelistchange(m, print_groupnamelistchange, NULL); initscr(); noecho(); diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 889de367..acb038df 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -779,20 +779,51 @@ void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int, m->group_message = function; m->group_message_userdata = userdata; } -static void group_message_function(Group_Chat *chat, int peer_number, uint8_t *message, uint16_t length, void *userdata) + +/* Set callback function for peer name list changes. + * + * It gets called every time the name list changes(new peer/name, deleted peer) + * Function(Tox *tox, int groupnumber, void *userdata) + */ +void m_callback_group_namelistchange(Messenger *m, void (*function)(Messenger *m, int, void *), void *userdata) { - Messenger *m = userdata; - uint32_t i; + m->group_namelistchange = function; + m->group_namelistchange_userdata = userdata; +} +static int get_chat_num(Messenger *m, Group_Chat *chat) +{ + uint32_t i; for (i = 0; i < m->numchats; ++i) { //TODO: remove this if (m->chats[i] == chat) - break; + return i; } + return -1; +} + +static void group_message_function(Group_Chat *chat, int peer_number, uint8_t *message, uint16_t length, void *userdata) +{ + Messenger *m = userdata; + int i = get_chat_num(m, chat); + if (i == -1) + return; if (m->group_message) (*m->group_message)(m, i, peer_number, message, length, m->group_message_userdata); } +static void group_namelistchange_function(Group_Chat *chat, void *userdata) +{ + Messenger *m = userdata; + int i = get_chat_num(m, chat); + if (i == -1) + return; + + if (m->group_namelistchange) + (*m->group_namelistchange)(m, i, m->group_namelistchange_userdata); +} + + /* Creates a new groupchat and puts it in the chats array. * * return group number on success. @@ -810,6 +841,7 @@ int add_groupchat(Messenger *m) return -1; callback_groupmessage(newchat, &group_message_function, m); + callback_namelistchange(newchat, &group_namelistchange_function, m); /* TODO: remove this (group nicks should not be tied to the global one) */ set_nick(newchat, m->name, m->name_length); m->chats[i] = newchat; @@ -830,6 +862,7 @@ int add_groupchat(Messenger *m) m->chats = temp; callback_groupmessage(temp[m->numchats], &group_message_function, m); + callback_namelistchange(temp[m->numchats], &group_namelistchange_function, m); /* TODO: remove this (group nicks should not be tied to the global one) */ set_nick(temp[m->numchats], m->name, m->name_length); ++m->numchats; diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 651f3f12..bf8a0572 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -198,6 +198,8 @@ typedef struct Messenger { void *group_invite_userdata; void (*group_message)(struct Messenger *m, int, int, uint8_t *, uint16_t, void *); void *group_message_userdata; + void (*group_namelistchange)(struct Messenger *m, int, void *); + void *group_namelistchange_userdata; void (*file_sendrequest)(struct Messenger *m, int, uint8_t, uint64_t, uint8_t *, uint16_t, void *); void *file_sendrequest_userdata; @@ -455,6 +457,13 @@ void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int, u void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int, int, uint8_t *, uint16_t, void *), void *userdata); +/* Set callback function for peer name list changes. + * + * It gets called every time the name list changes(new peer/name, deleted peer) + * Function(Tox *tox, int groupnumber, void *userdata) + */ +void m_callback_group_namelistchange(Messenger *m, void (*function)(Messenger *m, int, void *), void *userdata); + /* Creates a new groupchat and puts it in the chats array. * * return group number on success. diff --git a/toxcore/group_chats.c b/toxcore/group_chats.c index 34c84c40..7e18a334 100644 --- a/toxcore/group_chats.c +++ b/toxcore/group_chats.c @@ -218,6 +218,9 @@ static int addpeer(Group_Chat *chat, uint8_t *client_id) chat->group[chat->numpeers].last_recv_msgping = unix_time(); ++chat->numpeers; + if (chat->peer_namelistchange != NULL) + (*chat->peer_namelistchange)(chat, chat->group_namelistchange_userdata); + return (chat->numpeers - 1); } @@ -250,6 +253,10 @@ static int delpeer(Group_Chat *chat, int peernum) return -1; chat->group = temp; + + if (chat->peer_namelistchange != NULL) + (*chat->peer_namelistchange)(chat, chat->group_namelistchange_userdata); + return 0; } @@ -283,6 +290,8 @@ static void setnick(Group_Chat *chat, int peernum, uint8_t *contents, uint16_t c /* Force null termination */ chat->group[peernum].nick[contents_len - 1] = 0; chat->group[peernum].nick_len = contents_len; + if (chat->peer_namelistchange != NULL) + (*chat->peer_namelistchange)(chat, chat->group_namelistchange_userdata); } /* min time between pings sent to one peer in seconds */ @@ -616,6 +625,12 @@ void callback_groupmessage(Group_Chat *chat, void (*function)(Group_Chat *chat, chat->group_message_userdata = userdata; } +void callback_namelistchange(Group_Chat *chat, void (*function)(Group_Chat *chat, void *), void *userdata) +{ + chat->peer_namelistchange = function; + chat->group_namelistchange_userdata = userdata; +} + uint32_t group_numpeers(Group_Chat *chat) { return chat->numpeers; diff --git a/toxcore/group_chats.h b/toxcore/group_chats.h index 4257b1f5..2235a6e3 100644 --- a/toxcore/group_chats.h +++ b/toxcore/group_chats.h @@ -65,6 +65,8 @@ typedef struct Group_Chat { uint32_t message_number; void (*group_message)(struct Group_Chat *m, int, uint8_t *, uint16_t, void *); void *group_message_userdata; + void (*peer_namelistchange)(struct Group_Chat *m, void *); + void *group_namelistchange_userdata; uint64_t last_sent_ping; @@ -94,9 +96,16 @@ int group_peername(Group_Chat *chat, int peernum, uint8_t *name); * * format of function is: function(Group_Chat *chat, peer number, message, message length, userdata) */ - void callback_groupmessage(Group_Chat *chat, void (*function)(Group_Chat *chat, int, uint8_t *, uint16_t, void *), void *userdata); +/* + * Set callback function for peer name list changes. + * + * It gets called every time the name list changes(new peer/name, deleted peer) + * + * format of function is: function(Group_Chat *chat, userdata) + */ +void callback_namelistchange(Group_Chat *chat, void (*function)(Group_Chat *chat, void *), void *userdata); /* * Send a message to the group. diff --git a/toxcore/tox.c b/toxcore/tox.c index b5e754bb..4ba17e34 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -415,6 +415,19 @@ void tox_callback_group_message(Tox *tox, void (*function)(Messenger *tox, int, Messenger *m = tox; m_callback_group_message(m, function, userdata); } + +/* Set callback function for peer name list changes. + * + * It gets called every time the name list changes(new peer/name, deleted peer) + * Function(Tox *tox, int groupnumber, void *userdata) + */ + +void tox_callback_group_namelistchange(Tox *tox, void (*function)(Tox *tox, int, void *), void *userdata) +{ + Messenger *m = tox; + m_callback_group_namelistchange(m, function, userdata); +} + /* Creates a new groupchat and puts it in the chats array. * * return group number on success. diff --git a/toxcore/tox.h b/toxcore/tox.h index a0093ff3..fedc2c8a 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -363,6 +363,14 @@ void tox_callback_group_invite(Tox *tox, void (*function)(Tox *tox, int, uint8_t void tox_callback_group_message(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t *, uint16_t, void *), void *userdata); +/* Set callback function for peer name list changes. + * + * It gets called every time the name list changes(new peer/name, deleted peer) + * Function(Tox *tox, int groupnumber, void *userdata) + */ + +void tox_callback_group_namelistchange(Tox *tox, void (*function)(Tox *tox, int, void *), void *userdata); + /* Creates a new groupchat and puts it in the chats array. * * return group number on success. -- cgit v1.2.3 From e85e9dbb999f1fccd2083224cc52eebe29915bfe Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Sun, 24 Nov 2013 21:11:54 +0100 Subject: group_namelistchange(): for ui reasons, divulge the peernumber and the nature of the change (add, del, name change). tox.*, Messenger.*, group_chats.*: - expand interface of callback by peernumber/change groupchats.c: - call callback in addpeer/delpeer/setnick with peernumber and flag nTox.c: - print_groupchatpeers(): print as many names on a line as possible, not one peer per line - print_groupnamelistchange(): only print the change, if possible (i.e. "new peer", "peer's new name") - added command "/p" to print the list of peers --- testing/nTox.c | 98 +++++++++++++++++++++++++++++++++++++++++++++------ toxcore/Messenger.c | 6 ++-- toxcore/Messenger.h | 4 +-- toxcore/group_chats.c | 8 ++--- toxcore/group_chats.h | 10 ++++-- toxcore/tox.c | 2 +- toxcore/tox.h | 9 +++-- 7 files changed, 112 insertions(+), 25 deletions(-) (limited to 'toxcore/tox.c') diff --git a/testing/nTox.c b/testing/nTox.c index e7216d33..24054f5e 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -92,9 +92,10 @@ char *help_friend2 = /* 216 characters */ char *help_group = "[i] Available group commands:\n+ " - "/g (to create a new group)|" + "/g (to create a group)|" "/i friend no. group no. (to invite a friend to a group)|" "/z group no. message (to send a message to a group)|" + "/p group no. (to list a group's peers)|" "/cg group no. (to talk to that group per default)"; int x, y; @@ -346,8 +347,9 @@ static void print_formatted_message(Tox *m, char *message, int friendnum, uint8_ new_lines(msg); } -/* forward declaration */ +/* forward declarations */ static int save_data(Tox *m); +void print_groupchatpeers(Tox *m, int groupnumber); void line_eval(Tox *m, char *line) { @@ -561,6 +563,25 @@ void line_eval(Tox *m, char *line) } else new_lines("[i] invalid command"); } + } else if (inpt_command == 'p') { //list peers + char *posi = NULL; + int group_number = strtoul(line + prompt_offset, &posi, 0); + + if (posi != NULL) { + char msg[64]; + int peer_cnt = tox_group_number_peers(m, group_number); + + if (peer_cnt < 0) { + new_lines("[g] Invalid group number."); + } else if (peer_cnt == 0) { + sprintf(msg, "[g] #%i: No peers in group.", group_number); + new_lines(msg); + } else { + sprintf(msg, "[g] #%i: Group has %i peers. Names:", group_number, peer_cnt); + new_lines(msg); + print_groupchatpeers(m, group_number); + } + } } else { new_lines("[i] invalid command"); } @@ -974,24 +995,60 @@ void print_invite(Tox *m, int friendnumber, uint8_t *group_public_key, void *use tox_join_groupchat(m, friendnumber, group_public_key)); new_lines(msg); } + void print_groupchatpeers(Tox *m, int groupnumber) { - char msg[256]; int num = tox_group_number_peers(m, groupnumber); - if (num == -1) + + if (num < 0) return; + if (!num) { + new_lines("[g]+ no peers left in group."); + return; + } + uint8_t names[num][TOX_MAX_NAME_LENGTH]; tox_group_copy_names(m, groupnumber, names, num); - uint32_t i; - for (i = 0; i < num; ++i) - new_lines(names[i]); + int i; + char numstr[16]; + char header[] = "[g]+ "; + size_t header_len = strlen(header); + char msg[STRING_LENGTH]; + strcpy(msg, header); + size_t len_total = header_len; + + for (i = 0; i < num; ++i) { + size_t len_name = strlen((char *)names[i]); + size_t len_num = sprintf(numstr, "%i: ", i); + + if (len_num + len_name + len_total + 3 >= STRING_LENGTH) { + new_lines_mark(msg, 1); + + strcpy(msg, header); + len_total = header_len; + } + + strcpy(msg + len_total, numstr); + len_total += len_num; + strcpy(msg + len_total, (char *)names[i]); + len_total += len_name; + + if (i < num - 1) { + strcpy(msg + len_total, "|"); + len_total++; + } + } + + new_lines_mark(msg, 1); } + void print_groupmessage(Tox *m, int groupnumber, int peernumber, uint8_t *message, uint16_t length, void *userdata) { char msg[256 + length]; uint8_t name[TOX_MAX_NAME_LENGTH]; int len = tox_group_peername(m, groupnumber, peernumber, name); + //print_groupchatpeers(m, groupnumber); if (len <= 0) name[0] = 0; @@ -1003,12 +1060,31 @@ void print_groupmessage(Tox *m, int groupnumber, int peernumber, uint8_t *messag new_lines(msg); } -void print_groupnamelistchange(Tox *m, int groupnumber, void *userdata) +void print_groupnamelistchange(Tox *m, int groupnumber, int peernumber, uint8_t change, void *userdata) { char msg[256]; - sprintf(msg, "[g] %u: Name list changed:", groupnumber); - new_lines(msg); - print_groupchatpeers(m, groupnumber); + + if (change == TOX_CHAT_CHANGE_PEER_ADD) { + sprintf(msg, "[g] #%i: New peer %i.", groupnumber, peernumber); + new_lines(msg); + } else if (change == TOX_CHAT_CHANGE_PEER_DEL) { + sprintf(msg, "[g] #%i: Peer %i left. Name list is now:", groupnumber, peernumber); + new_lines(msg); + print_groupchatpeers(m, groupnumber); + } else if (change == TOX_CHAT_CHANGE_PEER_NAME) { + uint8_t peername[TOX_MAX_NAME_LENGTH]; + int len = tox_group_peername(m, groupnumber, peernumber, peername); + + if (len <= 0) + peername[0] = 0; + + sprintf(msg, "[g] #%i: Peer %i's name changed: %s", groupnumber, peernumber, peername); + new_lines(msg); + } else { + sprintf(msg, "[g] #%i: Name list changed (peer %i, change %i?):", groupnumber, peernumber, change); + new_lines(msg); + print_groupchatpeers(m, groupnumber); + } } void file_request_accept(Tox *m, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index cc52c069..1a7fc230 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -785,7 +785,7 @@ void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int, * It gets called every time the name list changes(new peer/name, deleted peer) * Function(Tox *tox, int groupnumber, void *userdata) */ -void m_callback_group_namelistchange(Messenger *m, void (*function)(Messenger *m, int, void *), void *userdata) +void m_callback_group_namelistchange(Messenger *m, void (*function)(Messenger *m, int, int, uint8_t, void *), void *userdata) { m->group_namelistchange = function; m->group_namelistchange_userdata = userdata; @@ -812,7 +812,7 @@ static void group_message_function(Group_Chat *chat, int peer_number, uint8_t *m (*m->group_message)(m, i, peer_number, message, length, m->group_message_userdata); } -static void group_namelistchange_function(Group_Chat *chat, void *userdata) +static void group_namelistchange_function(Group_Chat *chat, int peer, uint8_t change, void *userdata) { Messenger *m = userdata; int i = get_chat_num(m, chat); @@ -820,7 +820,7 @@ static void group_namelistchange_function(Group_Chat *chat, void *userdata) return; if (m->group_namelistchange) - (*m->group_namelistchange)(m, i, m->group_namelistchange_userdata); + (*m->group_namelistchange)(m, i, peer, change, m->group_namelistchange_userdata); } diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index bf8a0572..6fc23db4 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -198,7 +198,7 @@ typedef struct Messenger { void *group_invite_userdata; void (*group_message)(struct Messenger *m, int, int, uint8_t *, uint16_t, void *); void *group_message_userdata; - void (*group_namelistchange)(struct Messenger *m, int, void *); + void (*group_namelistchange)(struct Messenger *m, int, int, uint8_t, void *); void *group_namelistchange_userdata; void (*file_sendrequest)(struct Messenger *m, int, uint8_t, uint64_t, uint8_t *, uint16_t, void *); @@ -462,7 +462,7 @@ void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int, * It gets called every time the name list changes(new peer/name, deleted peer) * Function(Tox *tox, int groupnumber, void *userdata) */ -void m_callback_group_namelistchange(Messenger *m, void (*function)(Messenger *m, int, void *), void *userdata); +void m_callback_group_namelistchange(Messenger *m, void (*function)(Messenger *m, int, int, uint8_t, void *), void *userdata); /* Creates a new groupchat and puts it in the chats array. * diff --git a/toxcore/group_chats.c b/toxcore/group_chats.c index 7e18a334..a20ec555 100644 --- a/toxcore/group_chats.c +++ b/toxcore/group_chats.c @@ -219,7 +219,7 @@ static int addpeer(Group_Chat *chat, uint8_t *client_id) ++chat->numpeers; if (chat->peer_namelistchange != NULL) - (*chat->peer_namelistchange)(chat, chat->group_namelistchange_userdata); + (*chat->peer_namelistchange)(chat, chat->numpeers - 1, CHAT_CHANGE_PEER_ADD, chat->group_namelistchange_userdata); return (chat->numpeers - 1); } @@ -255,7 +255,7 @@ static int delpeer(Group_Chat *chat, int peernum) chat->group = temp; if (chat->peer_namelistchange != NULL) - (*chat->peer_namelistchange)(chat, chat->group_namelistchange_userdata); + (*chat->peer_namelistchange)(chat, peernum, CHAT_CHANGE_PEER_DEL, chat->group_namelistchange_userdata); return 0; } @@ -291,7 +291,7 @@ static void setnick(Group_Chat *chat, int peernum, uint8_t *contents, uint16_t c chat->group[peernum].nick[contents_len - 1] = 0; chat->group[peernum].nick_len = contents_len; if (chat->peer_namelistchange != NULL) - (*chat->peer_namelistchange)(chat, chat->group_namelistchange_userdata); + (*chat->peer_namelistchange)(chat, peernum, CHAT_CHANGE_PEER_NAME, chat->group_namelistchange_userdata); } /* min time between pings sent to one peer in seconds */ @@ -625,7 +625,7 @@ void callback_groupmessage(Group_Chat *chat, void (*function)(Group_Chat *chat, chat->group_message_userdata = userdata; } -void callback_namelistchange(Group_Chat *chat, void (*function)(Group_Chat *chat, void *), void *userdata) +void callback_namelistchange(Group_Chat *chat, void (*function)(Group_Chat *chat, int peer, uint8_t change, void *), void *userdata) { chat->peer_namelistchange = function; chat->group_namelistchange_userdata = userdata; diff --git a/toxcore/group_chats.h b/toxcore/group_chats.h index 2235a6e3..65f573fb 100644 --- a/toxcore/group_chats.h +++ b/toxcore/group_chats.h @@ -65,7 +65,7 @@ typedef struct Group_Chat { uint32_t message_number; void (*group_message)(struct Group_Chat *m, int, uint8_t *, uint16_t, void *); void *group_message_userdata; - void (*peer_namelistchange)(struct Group_Chat *m, void *); + void (*peer_namelistchange)(struct Group_Chat *m, int peer, uint8_t change, void *); void *group_namelistchange_userdata; uint64_t last_sent_ping; @@ -105,7 +105,13 @@ void callback_groupmessage(Group_Chat *chat, void (*function)(Group_Chat *chat, * * format of function is: function(Group_Chat *chat, userdata) */ -void callback_namelistchange(Group_Chat *chat, void (*function)(Group_Chat *chat, void *), void *userdata); +typedef enum { + CHAT_CHANGE_PEER_ADD, + CHAT_CHANGE_PEER_DEL, + CHAT_CHANGE_PEER_NAME, +} CHAT_CHANGE; + +void callback_namelistchange(Group_Chat *chat, void (*function)(Group_Chat *chat, int peer, uint8_t change, void *), void *userdata); /* * Send a message to the group. diff --git a/toxcore/tox.c b/toxcore/tox.c index 4ba17e34..d5bc1c35 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -422,7 +422,7 @@ void tox_callback_group_message(Tox *tox, void (*function)(Messenger *tox, int, * Function(Tox *tox, int groupnumber, void *userdata) */ -void tox_callback_group_namelistchange(Tox *tox, void (*function)(Tox *tox, int, void *), void *userdata) +void tox_callback_group_namelistchange(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t, void *), void *userdata) { Messenger *m = tox; m_callback_group_namelistchange(m, function, userdata); diff --git a/toxcore/tox.h b/toxcore/tox.h index fedc2c8a..08727d2a 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -366,10 +366,15 @@ void tox_callback_group_message(Tox *tox, void (*function)(Tox *tox, int, int, u /* Set callback function for peer name list changes. * * It gets called every time the name list changes(new peer/name, deleted peer) - * Function(Tox *tox, int groupnumber, void *userdata) + * Function(Tox *tox, int groupnumber, int peernumber, TOX_CHAT_CHANGE change, void *userdata) */ +typedef enum { + TOX_CHAT_CHANGE_PEER_ADD, + TOX_CHAT_CHANGE_PEER_DEL, + TOX_CHAT_CHANGE_PEER_NAME, +} TOX_CHAT_CHANGE; -void tox_callback_group_namelistchange(Tox *tox, void (*function)(Tox *tox, int, void *), void *userdata); +void tox_callback_group_namelistchange(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t, void *), void *userdata); /* Creates a new groupchat and puts it in the chats array. * -- cgit v1.2.3 From eec31edb1c6fe5d0ffdc79f6b38a89f6a4a9b20d Mon Sep 17 00:00:00 2001 From: AZ Huang Date: Fri, 29 Nov 2013 18:26:09 +0800 Subject: Fix return code inconsistency. --- testing/nTox.c | 6 +++--- toxcore/Messenger.c | 44 ++++++++++++++++++++++---------------------- toxcore/tox.c | 12 ++++++------ toxcore/tox.h | 12 ++++++------ 4 files changed, 37 insertions(+), 37 deletions(-) (limited to 'toxcore/tox.c') diff --git a/testing/nTox.c b/testing/nTox.c index 2dd8b874..6e333abf 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -131,8 +131,8 @@ void send_filesenders(Tox *m) continue; while (1) { - if (!tox_file_senddata(m, file_senders[i].friendnum, file_senders[i].filenumber, file_senders[i].nextpiece, - file_senders[i].piecelength)) + if (tox_file_senddata(m, file_senders[i].friendnum, file_senders[i].filenumber, file_senders[i].nextpiece, + file_senders[i].piecelength) == -1) break; file_senders[i].piecelength = fread(file_senders[i].nextpiece, 1, tox_filedata_size(m, file_senders[i].friendnum), @@ -1182,7 +1182,7 @@ void file_request_accept(Tox *m, int friendnumber, uint8_t filenumber, uint64_t sprintf(msg, "[t] %u is sending us: %s of size %llu", friendnumber, filename, (long long unsigned int)filesize); new_lines(msg); - if (tox_file_sendcontrol(m, friendnumber, 1, filenumber, 0, 0, 0)) { + if (tox_file_sendcontrol(m, friendnumber, 1, filenumber, 0, 0, 0) == 0) { sprintf(msg, "Accepted file transfer. (saving file as: %u.%u.bin)", friendnumber, filenumber); new_lines(msg); } else diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 5e9758dd..a3295170 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -1185,28 +1185,28 @@ int new_filesender(Messenger *m, int friendnumber, uint64_t filesize, uint8_t *f /* Send a file control request. * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file. * - * return 1 on success - * return 0 on failure + * return 0 on success + * return -1 on failure */ int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, uint8_t *data, uint16_t length) { if (length > MAX_DATA_SIZE - 3) - return 0; + return -1; if (friend_not_valid(m, friendnumber)) - return 0; + return -1; if (send_receive == 1) { if (m->friendlist[friendnumber].file_receiving[filenumber].status == FILESTATUS_NONE) - return 0; + return -1; } else { if (m->friendlist[friendnumber].file_sending[filenumber].status == FILESTATUS_NONE) - return 0; + return -1; } if (send_receive > 1) - return 0; + return -1; uint8_t packet[MAX_DATA_SIZE]; packet[0] = send_receive; @@ -1216,7 +1216,7 @@ int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t f if (message_id == FILECONTROL_RESUME_BROKEN) { if (length != sizeof(uint64_t)) - return 0; + return -1; uint8_t remaining[sizeof(uint64_t)]; memcpy(remaining, data, sizeof(uint64_t)); @@ -1264,32 +1264,32 @@ int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t f break; } - return 1; - } else { return 0; + } else { + return -1; } } #define MIN_SLOTS_FREE 4 /* Send file data. * - * return 1 on success - * return 0 on failure + * return 0 on success + * return -1 on failure */ int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length) { if (length > MAX_DATA_SIZE - 1) - return 0; + return -1; if (friend_not_valid(m, friendnumber)) - return 0; + return -1; if (m->friendlist[friendnumber].file_sending[filenumber].status != FILESTATUS_TRANSFERRING) - return 0; + return -1; /* Prevent file sending from filling up the entire buffer preventing messages from being sent. */ if (crypto_num_free_sendqueue_slots(m->net_crypto, m->friendlist[friendnumber].crypt_connection_id) < MIN_SLOTS_FREE) - return 0; + return -1; uint8_t packet[MAX_DATA_SIZE]; packet[0] = filenumber; @@ -1297,10 +1297,10 @@ int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data, if (write_cryptpacket_id(m, friendnumber, PACKET_ID_FILE_DATA, packet, length + 1)) { m->friendlist[friendnumber].file_sending[filenumber].transferred += length; - return 1; + return 0; } - return 0; + return -1; } @@ -1309,22 +1309,22 @@ int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data, * send_receive is 0 if we want the sending files, 1 if we want the receiving. * * return number of bytes remaining to be sent/received on success - * return 0 on failure + * return -1 on failure */ uint64_t file_dataremaining(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t send_receive) { if (friend_not_valid(m, friendnumber)) - return 0; + return -1; if (send_receive == 0) { if (m->friendlist[friendnumber].file_sending[filenumber].status == FILESTATUS_NONE) - return 0; + return -1; return m->friendlist[friendnumber].file_sending[filenumber].size - m->friendlist[friendnumber].file_sending[filenumber].transferred; } else { if (m->friendlist[friendnumber].file_receiving[filenumber].status == FILESTATUS_NONE) - return 0; + return -1; return m->friendlist[friendnumber].file_receiving[filenumber].size - m->friendlist[friendnumber].file_receiving[filenumber].transferred; diff --git a/toxcore/tox.c b/toxcore/tox.c index d5bc1c35..02137b3c 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -585,8 +585,8 @@ int tox_new_filesender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *f /* Send a file control request. * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file. * - * return 1 on success - * return 0 on failure + * return 0 on success + * return -1 on failure */ int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, uint8_t *data, uint16_t length) @@ -596,8 +596,8 @@ int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8 } /* Send file data. * - * return 1 on success - * return 0 on failure + * return 0 on success + * return -1 on failure */ int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length) { @@ -608,7 +608,7 @@ int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *d /* Returns the recommended/maximum size of the filedata you send with tox_file_senddata() * * return size on success - * return 0 on failure (currently will never return 0) + * return -1 on failure (currently will never return -1) */ int tox_filedata_size(Tox *tox, int friendnumber) { @@ -620,7 +620,7 @@ int tox_filedata_size(Tox *tox, int friendnumber) * send_receive is 0 if we want the sending files, 1 if we want the receiving. * * return number of bytes remaining to be sent/received on success - * return 0 on failure + * return -1 on failure */ uint64_t tox_file_dataremaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive) { diff --git a/toxcore/tox.h b/toxcore/tox.h index 469a1f78..735d991a 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -519,23 +519,23 @@ int tox_new_filesender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *f * send_receive is 0 if we want the control packet to target a file we are currently sending, * 1 if it targets a file we are currently receiving. * - * return 1 on success - * return 0 on failure + * return 0 on success + * return -1 on failure */ int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, uint8_t *data, uint16_t length); /* Send file data. * - * return 1 on success - * return 0 on failure + * return 0 on success + * return -1 on failure */ int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length); /* Returns the recommended/maximum size of the filedata you send with tox_file_senddata() * * return size on success - * return 0 on failure (currently will never return 0) + * return -1 on failure (currently will never return -1) */ int tox_filedata_size(Tox *tox, int friendnumber); @@ -544,7 +544,7 @@ int tox_filedata_size(Tox *tox, int friendnumber); * send_receive is 0 if we want the sending files, 1 if we want the receiving. * * return number of bytes remaining to be sent/received on success - * return 0 on failure + * return -1 on failure */ uint64_t tox_file_dataremaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive); -- cgit v1.2.3 From 1df2d5880db375b6a2d5259bb8ff2560c9f1007d Mon Sep 17 00:00:00 2001 From: AZ Huang Date: Fri, 29 Nov 2013 22:26:29 +0800 Subject: Should return 0 for tox_file_dataremaining since it returns unsigned --- toxcore/Messenger.c | 6 +++--- toxcore/tox.c | 2 +- toxcore/tox.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'toxcore/tox.c') diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index a3295170..954b31dd 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -1314,17 +1314,17 @@ int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data, uint64_t file_dataremaining(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t send_receive) { if (friend_not_valid(m, friendnumber)) - return -1; + return 0; if (send_receive == 0) { if (m->friendlist[friendnumber].file_sending[filenumber].status == FILESTATUS_NONE) - return -1; + return 0; return m->friendlist[friendnumber].file_sending[filenumber].size - m->friendlist[friendnumber].file_sending[filenumber].transferred; } else { if (m->friendlist[friendnumber].file_receiving[filenumber].status == FILESTATUS_NONE) - return -1; + return 0; return m->friendlist[friendnumber].file_receiving[filenumber].size - m->friendlist[friendnumber].file_receiving[filenumber].transferred; diff --git a/toxcore/tox.c b/toxcore/tox.c index 02137b3c..f4e65ec8 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -620,7 +620,7 @@ int tox_filedata_size(Tox *tox, int friendnumber) * send_receive is 0 if we want the sending files, 1 if we want the receiving. * * return number of bytes remaining to be sent/received on success - * return -1 on failure + * return 0 on failure */ uint64_t tox_file_dataremaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive) { diff --git a/toxcore/tox.h b/toxcore/tox.h index 735d991a..ea373488 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -544,7 +544,7 @@ int tox_filedata_size(Tox *tox, int friendnumber); * send_receive is 0 if we want the sending files, 1 if we want the receiving. * * return number of bytes remaining to be sent/received on success - * return -1 on failure + * return 0 on failure */ uint64_t tox_file_dataremaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive); -- cgit v1.2.3 From 8419d3469a843684ba51a774663db848cfaab615 Mon Sep 17 00:00:00 2001 From: AZ Huang Date: Fri, 29 Nov 2013 23:12:07 +0800 Subject: Fix API name consistency. --- testing/nTox.c | 50 +++++++++++++++---------------- testing/tox_sync.c | 26 ++++++++--------- toxcore/tox.c | 74 +++++++++++++++++++++++----------------------- toxcore/tox.h | 86 +++++++++++++++++++++++++++--------------------------- 4 files changed, 118 insertions(+), 118 deletions(-) (limited to 'toxcore/tox.c') diff --git a/testing/nTox.c b/testing/nTox.c index 6e333abf..acd7d971 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -131,17 +131,17 @@ void send_filesenders(Tox *m) continue; while (1) { - if (tox_file_senddata(m, file_senders[i].friendnum, file_senders[i].filenumber, file_senders[i].nextpiece, + if (tox_file_send_data(m, file_senders[i].friendnum, file_senders[i].filenumber, file_senders[i].nextpiece, file_senders[i].piecelength) == -1) break; - file_senders[i].piecelength = fread(file_senders[i].nextpiece, 1, tox_filedata_size(m, file_senders[i].friendnum), + file_senders[i].piecelength = fread(file_senders[i].nextpiece, 1, tox_file_data_size(m, file_senders[i].friendnum), file_senders[i].file); if (file_senders[i].piecelength == 0) { fclose(file_senders[i].file); file_senders[i].file = 0; - tox_file_sendcontrol(m, file_senders[i].friendnum, 0, file_senders[i].filenumber, 3, 0, 0); + tox_file_send_control(m, file_senders[i].friendnum, 0, file_senders[i].filenumber, 3, 0, 0); char msg[512]; sprintf(msg, "[t] %u file transfer: %u completed", file_senders[i].friendnum, file_senders[i].filenumber); new_lines(msg); @@ -160,13 +160,13 @@ int add_filesender(Tox *m, uint16_t friendnum, char *filename) fseek(tempfile, 0, SEEK_END); uint64_t filesize = ftell(tempfile); fseek(tempfile, 0, SEEK_SET); - int filenum = tox_new_filesender(m, friendnum, filesize, (uint8_t *)filename, strlen(filename) + 1); + int filenum = tox_new_file_sender(m, friendnum, filesize, (uint8_t *)filename, strlen(filename) + 1); if (filenum == -1) return -1; file_senders[numfilesenders].file = tempfile; - file_senders[numfilesenders].piecelength = fread(file_senders[numfilesenders].nextpiece, 1, tox_filedata_size(m, + file_senders[numfilesenders].piecelength = fread(file_senders[numfilesenders].nextpiece, 1, tox_file_data_size(m, file_senders[numfilesenders].friendnum), file_senders[numfilesenders].file); file_senders[numfilesenders].friendnum = friendnum; @@ -270,13 +270,13 @@ void get_id(Tox *m, char *data) sprintf(data, "[i] ID: "); int offset = strlen(data); uint8_t address[TOX_FRIEND_ADDRESS_SIZE]; - tox_getaddress(m, address); + tox_add_address(m, address); fraddr_to_str(address, data + offset); } int getfriendname_terminated(Tox *m, int friendnum, char *namebuf) { - int res = tox_getname(m, friendnum, (uint8_t *)namebuf); + int res = tox_get_name(m, friendnum, (uint8_t *)namebuf); if (res >= 0) namebuf[res] = 0; @@ -323,7 +323,7 @@ void print_friendlist(Tox *m) uint i = 0; while (getfriendname_terminated(m, i, name) != -1) { - if (!tox_getclient_id(m, i, fraddr_bin)) + if (!tox_get_client_id(m, i, fraddr_bin)) fraddr_to_str(fraddr_bin, fraddr_str); else sprintf(fraddr_str, "???"); @@ -406,7 +406,7 @@ void line_eval(Tox *m, char *line) } unsigned char *bin_string = hex_string_to_bin(temp_id); - int num = tox_addfriend(m, bin_string, (uint8_t *)"Install Gentoo", sizeof("Install Gentoo")); + int num = tox_add_friend(m, bin_string, (uint8_t *)"Install Gentoo", sizeof("Install Gentoo")); free(bin_string); char numstring[100]; @@ -449,7 +449,7 @@ void line_eval(Tox *m, char *line) int num = strtoul(line + prompt_offset, posi, 0); if (**posi != 0) { - if (tox_sendmessage(m, num, (uint8_t *) *posi + 1, strlen(*posi + 1) + 1) < 1) { + if (tox_send_message(m, num, (uint8_t *) *posi + 1, strlen(*posi + 1) + 1) < 1) { char sss[256]; sprintf(sss, "[i] could not send message to friend num %u", num); new_lines(sss); @@ -469,7 +469,7 @@ void line_eval(Tox *m, char *line) } name[i - 3] = 0; - tox_setname(m, name, i - 2); + tox_set_name(m, name, i - 2); char numstring[100]; sprintf(numstring, "[i] changed nick to %s", (char *)name); new_lines(numstring); @@ -486,7 +486,7 @@ void line_eval(Tox *m, char *line) } status[i - 3] = 0; - tox_set_statusmessage(m, status, strlen((char *)status) + 1); + tox_set_status_message(m, status, strlen((char *)status) + 1); char numstring[100]; sprintf(numstring, "[i] changed status to %s", (char *)status); new_lines(numstring); @@ -498,7 +498,7 @@ void line_eval(Tox *m, char *line) sprintf(numchar, "[i] you either didn't receive that request or you already accepted it"); new_lines(numchar); } else { - int num = tox_addfriend_norequest(m, pending_requests[numf].id); + int num = tox_add_friend_norequest(m, pending_requests[numf].id); if (num != -1) { pending_requests[numf].accepted = 1; @@ -534,7 +534,7 @@ void line_eval(Tox *m, char *line) } while ((c != 'y') && (c != 'n') && (c != EOF)); if (c == 'y') { - int res = tox_delfriend(m, numf); + int res = tox_del_friend(m, numf); if (res == 0) sprintf(msg, "[i] [%i: %s] is no longer your friend", numf, fname); @@ -660,7 +660,7 @@ void line_eval(Tox *m, char *line) if (conversation_default != 0) { if (conversation_default > 0) { int friendnumber = conversation_default - 1; - uint32_t res = tox_sendmessage(m, friendnumber, (uint8_t *)line, strlen(line) + 1); + uint32_t res = tox_send_message(m, friendnumber, (uint8_t *)line, strlen(line) + 1); if (res == 0) { char sss[128]; @@ -1080,7 +1080,7 @@ void print_groupchatpeers(Tox *m, int groupnumber) } uint8_t names[num][TOX_MAX_NAME_LENGTH]; - tox_group_copy_names(m, groupnumber, names, num); + tox_group_get_names(m, groupnumber, names, num); int i; char numstr[16]; char header[] = "[g]+ "; @@ -1182,7 +1182,7 @@ void file_request_accept(Tox *m, int friendnumber, uint8_t filenumber, uint64_t sprintf(msg, "[t] %u is sending us: %s of size %llu", friendnumber, filename, (long long unsigned int)filesize); new_lines(msg); - if (tox_file_sendcontrol(m, friendnumber, 1, filenumber, 0, 0, 0) == 0) { + if (tox_file_send_control(m, friendnumber, 1, filenumber, 0, 0, 0) == 0) { sprintf(msg, "Accepted file transfer. (saving file as: %u.%u.bin)", friendnumber, filenumber); new_lines(msg); } else @@ -1211,7 +1211,7 @@ void write_file(Tox *m, int friendnumber, uint8_t filenumber, uint8_t *data, uin sprintf(filename, "%u.%u.bin", friendnumber, filenumber); FILE *pFile = fopen(filename, "a"); - if (tox_file_dataremaining(m, friendnumber, filenumber, 1) == 0) { + if (tox_file_data_remaining(m, friendnumber, filenumber, 1) == 0) { //file_control(m, friendnumber, 1, filenumber, 3, 0, 0); char msg[512]; sprintf(msg, "[t] %u file transfer: %u completed", friendnumber, filenumber); @@ -1267,16 +1267,16 @@ int main(int argc, char *argv[]) load_data_or_init(m, filename); - tox_callback_friendrequest(m, print_request, NULL); - tox_callback_friendmessage(m, print_message, NULL); - tox_callback_namechange(m, print_nickchange, NULL); - tox_callback_statusmessage(m, print_statuschange, NULL); + tox_callback_friend_request(m, print_request, NULL); + tox_callback_friend_message(m, print_message, NULL); + tox_callback_name_change(m, print_nickchange, NULL); + tox_callback_status_message(m, print_statuschange, NULL); tox_callback_group_invite(m, print_invite, NULL); tox_callback_group_message(m, print_groupmessage, NULL); tox_callback_file_data(m, write_file, NULL); tox_callback_file_control(m, file_print_control, NULL); - tox_callback_file_sendrequest(m, file_request_accept, NULL); - tox_callback_group_namelistchange(m, print_groupnamelistchange, NULL); + tox_callback_file_send_request(m, file_request_accept, NULL); + tox_callback_group_namelist_change(m, print_groupnamelistchange, NULL); initscr(); noecho(); @@ -1303,7 +1303,7 @@ int main(int argc, char *argv[]) new_lines("[i] change username with /n"); uint8_t name[TOX_MAX_NAME_LENGTH + 1]; - uint16_t namelen = tox_getselfname(m, name, sizeof(name)); + uint16_t namelen = tox_get_self_name(m, name, sizeof(name)); name[namelen] = 0; if (namelen > 0) { diff --git a/testing/tox_sync.c b/testing/tox_sync.c index 3207e297..ce5d9578 100644 --- a/testing/tox_sync.c +++ b/testing/tox_sync.c @@ -62,11 +62,11 @@ void send_filesenders(Tox *m) continue; while (1) { - if (!tox_file_senddata(m, file_senders[i].friendnum, file_senders[i].filenumber, file_senders[i].nextpiece, + if (!tox_file_send_data(m, file_senders[i].friendnum, file_senders[i].filenumber, file_senders[i].nextpiece, file_senders[i].piecelength)) break; - file_senders[i].piecelength = fread(file_senders[i].nextpiece, 1, tox_filedata_size(m, file_senders[i].friendnum), + file_senders[i].piecelength = fread(file_senders[i].nextpiece, 1, tox_file_data_size(m, file_senders[i].friendnum), file_senders[i].file); if (file_senders[i].piecelength == 0) { @@ -74,7 +74,7 @@ void send_filesenders(Tox *m) file_senders[i].file = 0; printf("[t] %u file transfer: %u completed %i\n", file_senders[i].friendnum, file_senders[i].filenumber, - tox_file_sendcontrol(m, file_senders[i].friendnum, 0, file_senders[i].filenumber, TOX_FILECONTROL_FINISHED, 0, 0)); + tox_file_send_control(m, file_senders[i].friendnum, 0, file_senders[i].filenumber, TOX_FILECONTROL_FINISHED, 0, 0)); break; } } @@ -90,13 +90,13 @@ int add_filesender(Tox *m, uint16_t friendnum, char *filename) fseek(tempfile, 0, SEEK_END); uint64_t filesize = ftell(tempfile); fseek(tempfile, 0, SEEK_SET); - int filenum = tox_new_filesender(m, friendnum, filesize, (uint8_t *)filename, strlen(filename) + 1); + int filenum = tox_new_file_sender(m, friendnum, filesize, (uint8_t *)filename, strlen(filename) + 1); if (filenum == -1) return -1; file_senders[numfilesenders].file = tempfile; - file_senders[numfilesenders].piecelength = fread(file_senders[numfilesenders].nextpiece, 1, tox_filedata_size(m, + file_senders[numfilesenders].piecelength = fread(file_senders[numfilesenders].nextpiece, 1, tox_file_data_size(m, file_senders[numfilesenders].friendnum), file_senders[numfilesenders].file); file_senders[numfilesenders].friendnum = friendnum; @@ -149,18 +149,18 @@ void file_request_accept(Tox *m, int friendnumber, uint8_t filenumber, uint64_t if (tempfile != 0) { fclose(tempfile); - tox_file_sendcontrol(m, friendnumber, 1, filenumber, TOX_FILECONTROL_KILL, 0, 0); + tox_file_send_control(m, friendnumber, 1, filenumber, TOX_FILECONTROL_KILL, 0, 0); return; } file_recv[filenumber].file = fopen(fullpath, "wb"); if (file_recv[filenumber].file == 0) { - tox_file_sendcontrol(m, friendnumber, 1, filenumber, TOX_FILECONTROL_KILL, 0, 0); + tox_file_send_control(m, friendnumber, 1, filenumber, TOX_FILECONTROL_KILL, 0, 0); return; } - if (tox_file_sendcontrol(m, friendnumber, 1, filenumber, TOX_FILECONTROL_ACCEPT, 0, 0)) { + if (tox_file_send_control(m, friendnumber, 1, filenumber, TOX_FILECONTROL_ACCEPT, 0, 0)) { printf("Accepted file transfer. (file: %s)\n", fullpath); } @@ -215,8 +215,8 @@ int main(int argc, char *argv[]) Tox *tox = tox_new(ipv6enabled); tox_callback_file_data(tox, write_file, NULL); tox_callback_file_control(tox, file_print_control, NULL); - tox_callback_file_sendrequest(tox, file_request_accept, NULL); - tox_callback_connectionstatus(tox, print_online, NULL); + tox_callback_file_send_request(tox, file_request_accept, NULL); + tox_callback_connection_status(tox, print_online, NULL); uint16_t port = htons(atoi(argv[argvoffset + 2])); unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); @@ -228,7 +228,7 @@ int main(int argc, char *argv[]) } uint8_t address[TOX_FRIEND_ADDRESS_SIZE]; - tox_getaddress(tox, address); + tox_add_address(tox, address); uint32_t i; for (i = 0; i < TOX_FRIEND_ADDRESS_SIZE; i++) { @@ -242,7 +242,7 @@ int main(int argc, char *argv[]) return 1; } - int num = tox_addfriend(tox, hex_string_to_bin(temp_id), (uint8_t *)"Install Gentoo", sizeof("Install Gentoo")); + int num = tox_add_friend(tox, hex_string_to_bin(temp_id), (uint8_t *)"Install Gentoo", sizeof("Install Gentoo")); if (num < 0) { printf("\nSomething went wrong when adding friend.\n"); @@ -260,7 +260,7 @@ int main(int argc, char *argv[]) notconnected = 0; } - if (not_sending() && tox_get_friend_connectionstatus(tox, num)) { + if (not_sending() && tox_get_friend_connection_status(tox, num)) { d = opendir(path); if (d) { diff --git a/toxcore/tox.c b/toxcore/tox.c index f4e65ec8..2066b685 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -37,7 +37,7 @@ typedef struct Messenger Tox; * Format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] * */ -void tox_getaddress(Tox *tox, uint8_t *address) +void tox_add_address(Tox *tox, uint8_t *address) { Messenger *m = tox; getaddress(m, address); @@ -60,7 +60,7 @@ void tox_getaddress(Tox *tox, uint8_t *address) * (the nospam for that friend was set to the new one). * return FAERR_NOMEM if increasing the friend list size fails. */ -int tox_addfriend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length) +int tox_add_friend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length) { Messenger *m = tox; return m_addfriend(m, address, data, length); @@ -71,7 +71,7 @@ int tox_addfriend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length) * return the friend number if success. * return -1 if failure. */ -int tox_addfriend_norequest(Tox *tox, uint8_t *client_id) +int tox_add_friend_norequest(Tox *tox, uint8_t *client_id) { Messenger *m = tox; return m_addfriend_norequest(m, client_id); @@ -80,7 +80,7 @@ int tox_addfriend_norequest(Tox *tox, uint8_t *client_id) /* return the friend id associated to that client id. * return -1 if no such friend. */ -int tox_getfriend_id(Tox *tox, uint8_t *client_id) +int tox_get_friend_id(Tox *tox, uint8_t *client_id) { Messenger *m = tox; return getfriend_id(m, client_id); @@ -92,14 +92,14 @@ int tox_getfriend_id(Tox *tox, uint8_t *client_id) * return 0 if success. * return -1 if failure. */ -int tox_getclient_id(Tox *tox, int friend_id, uint8_t *client_id) +int tox_get_client_id(Tox *tox, int friend_id, uint8_t *client_id) { Messenger *m = tox; return getclient_id(m, friend_id, client_id); } /* Remove a friend. */ -int tox_delfriend(Tox *tox, int friendnumber) +int tox_del_friend(Tox *tox, int friendnumber) { Messenger *m = tox; return m_delfriend(m, friendnumber); @@ -111,7 +111,7 @@ int tox_delfriend(Tox *tox, int friendnumber) * return 0 if friend is not connected to us (Offline). * return -1 on failure. */ -int tox_get_friend_connectionstatus(Tox *tox, int friendnumber) +int tox_get_friend_connection_status(Tox *tox, int friendnumber) { Messenger *m = tox; return m_get_friend_connectionstatus(m, friendnumber); @@ -137,13 +137,13 @@ int tox_friend_exists(Tox *tox, int friendnumber) * m_sendmessage_withid will send a message with the id of your choosing, * however we can generate an id for you by calling plain m_sendmessage. */ -uint32_t tox_sendmessage(Tox *tox, int friendnumber, uint8_t *message, uint32_t length) +uint32_t tox_send_message(Tox *tox, int friendnumber, uint8_t *message, uint32_t length) { Messenger *m = tox; return m_sendmessage(m, friendnumber, message, length); } -uint32_t tox_sendmessage_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *message, uint32_t length) +uint32_t tox_send_message_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *message, uint32_t length) { Messenger *m = tox; return m_sendmessage_withid(m, friendnumber, theid, message, length); @@ -159,13 +159,13 @@ uint32_t tox_sendmessage_withid(Tox *tox, int friendnumber, uint32_t theid, uint * m_sendaction_withid will send an action message with the id of your choosing, * however we can generate an id for you by calling plain m_sendaction. */ -uint32_t tox_sendaction(Tox *tox, int friendnumber, uint8_t *action, uint32_t length) +uint32_t tox_send_action(Tox *tox, int friendnumber, uint8_t *action, uint32_t length) { Messenger *m = tox; return m_sendaction(m, friendnumber, action, length); } -uint32_t tox_sendaction_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *action, uint32_t length) +uint32_t tox_send_action_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *action, uint32_t length) { Messenger *m = tox; return m_sendaction_withid(m, friendnumber, theid, action, length); @@ -179,7 +179,7 @@ uint32_t tox_sendaction_withid(Tox *tox, int friendnumber, uint32_t theid, uint8 * return 0 if success. * return -1 if failure. */ -int tox_setname(Tox *tox, uint8_t *name, uint16_t length) +int tox_set_name(Tox *tox, uint8_t *name, uint16_t length) { Messenger *m = tox; return setname(m, name, length); @@ -193,7 +193,7 @@ int tox_setname(Tox *tox, uint8_t *name, uint16_t length) * return length of the name. * return 0 on error. */ -uint16_t tox_getselfname(Tox *tox, uint8_t *name, uint16_t nlen) +uint16_t tox_get_self_name(Tox *tox, uint8_t *name, uint16_t nlen) { Messenger *m = tox; return getself_name(m, name, nlen); @@ -205,7 +205,7 @@ uint16_t tox_getselfname(Tox *tox, uint8_t *name, uint16_t nlen) * return length of name (with the NULL terminator) if success. * return -1 if failure. */ -int tox_getname(Tox *tox, int friendnumber, uint8_t *name) +int tox_get_name(Tox *tox, int friendnumber, uint8_t *name) { Messenger *m = tox; return getname(m, friendnumber, name); @@ -216,7 +216,7 @@ int tox_getname(Tox *tox, int friendnumber, uint8_t *name) * * return 0 on success, -1 on failure. */ -int tox_set_statusmessage(Tox *tox, uint8_t *status, uint16_t length) +int tox_set_status_message(Tox *tox, uint8_t *status, uint16_t length) { Messenger *m = tox; return m_set_statusmessage(m, status, length); @@ -231,7 +231,7 @@ int tox_set_userstatus(Tox *tox, TOX_USERSTATUS status) /* return the length of friendnumber's status message, including null. * Pass it into malloc. */ -int tox_get_statusmessage_size(Tox *tox, int friendnumber) +int tox_get_status_message_size(Tox *tox, int friendnumber) { Messenger *m = tox; return m_get_statusmessage_size(m, friendnumber); @@ -241,13 +241,13 @@ int tox_get_statusmessage_size(Tox *tox, int friendnumber) * Get the size you need to allocate from m_get_statusmessage_size. * The self variant will copy our own status message. */ -int tox_copy_statusmessage(Tox *tox, int friendnumber, uint8_t *buf, uint32_t maxlen) +int tox_get_status_message(Tox *tox, int friendnumber, uint8_t *buf, uint32_t maxlen) { Messenger *m = tox; return m_copy_statusmessage(m, friendnumber, buf, maxlen); } -int tox_copy_self_statusmessage(Tox *tox, uint8_t *buf, uint32_t maxlen) +int tox_get_self_status_message(Tox *tox, uint8_t *buf, uint32_t maxlen) { Messenger *m = tox; return m_copy_self_statusmessage(m, buf, maxlen); @@ -258,13 +258,13 @@ int tox_copy_self_statusmessage(Tox *tox, uint8_t *buf, uint32_t maxlen) * As above, the self variant will return our own USERSTATUS. * If friendnumber is invalid, this shall return USERSTATUS_INVALID. */ -TOX_USERSTATUS tox_get_userstatus(Tox *tox, int friendnumber) +TOX_USERSTATUS tox_get_user_status(Tox *tox, int friendnumber) { Messenger *m = tox; return (TOX_USERSTATUS)m_get_userstatus(m, friendnumber); } -TOX_USERSTATUS tox_get_selfuserstatus(Tox *tox) +TOX_USERSTATUS tox_get_self_user_status(Tox *tox) { Messenger *m = tox; return (TOX_USERSTATUS)m_get_self_userstatus(m); @@ -294,7 +294,7 @@ uint32_t tox_count_friendlist(Tox *tox) * Otherwise, returns the number of elements copied. * If the array was too small, the contents * of out_list will be truncated to list_size. */ -uint32_t tox_copy_friendlist(Tox *tox, int *out_list, uint32_t list_size) +uint32_t tox_get_friendlist(Tox *tox, int *out_list, uint32_t list_size) { Messenger *m = tox; return copy_friendlist(m, out_list, list_size); @@ -303,7 +303,7 @@ uint32_t tox_copy_friendlist(Tox *tox, int *out_list, uint32_t list_size) /* Set the function that will be executed when a friend request is received. * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */ -void tox_callback_friendrequest(Tox *tox, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata) +void tox_callback_friend_request(Tox *tox, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata) { Messenger *m = tox; m_callback_friendrequest(m, function, userdata); @@ -313,7 +313,7 @@ void tox_callback_friendrequest(Tox *tox, void (*function)(uint8_t *, uint8_t *, /* Set the function that will be executed when a message from a friend is received. * Function format is: function(int friendnumber, uint8_t * message, uint32_t length) */ -void tox_callback_friendmessage(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *), +void tox_callback_friend_message(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *), void *userdata) { Messenger *m = tox; @@ -333,7 +333,7 @@ void tox_callback_action(Tox *tox, void (*function)(Messenger *tox, int, uint8_t * function(int friendnumber, uint8_t *newname, uint16_t length) * You are not responsible for freeing newname. */ -void tox_callback_namechange(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *), +void tox_callback_name_change(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *), void *userdata) { Messenger *m = tox; @@ -344,7 +344,7 @@ void tox_callback_namechange(Tox *tox, void (*function)(Messenger *tox, int, uin * function(int friendnumber, uint8_t *newstatus, uint16_t length) * You are not responsible for freeing newstatus. */ -void tox_callback_statusmessage(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *), +void tox_callback_status_message(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *), void *userdata) { Messenger *m = tox; @@ -354,7 +354,7 @@ void tox_callback_statusmessage(Tox *tox, void (*function)(Messenger *tox, int, /* Set the callback for status type changes. * function(int friendnumber, USERSTATUS kind) */ -void tox_callback_userstatus(Tox *tox, void (*_function)(Tox *tox, int, TOX_USERSTATUS, void *), void *userdata) +void tox_callback_user_status(Tox *tox, void (*_function)(Tox *tox, int, TOX_USERSTATUS, void *), void *userdata) { Messenger *m = tox; typedef void (*function_type)(Messenger *, int, USERSTATUS, void *); @@ -388,7 +388,7 @@ void tox_callback_read_receipt(Tox *tox, void (*function)(Messenger *tox, int, u * being previously online" part. It's assumed that when adding friends, * their connection status is offline. */ -void tox_callback_connectionstatus(Tox *tox, void (*function)(Messenger *tox, int, uint8_t, void *), void *userdata) +void tox_callback_connection_status(Tox *tox, void (*function)(Messenger *tox, int, uint8_t, void *), void *userdata) { Messenger *m = tox; m_callback_connectionstatus(m, function, userdata); @@ -422,7 +422,7 @@ void tox_callback_group_message(Tox *tox, void (*function)(Messenger *tox, int, * Function(Tox *tox, int groupnumber, void *userdata) */ -void tox_callback_group_namelistchange(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t, void *), void *userdata) +void tox_callback_group_namelist_change(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t, void *), void *userdata) { Messenger *m = tox; m_callback_group_namelistchange(m, function, userdata); @@ -507,7 +507,7 @@ int tox_group_number_peers(Tox *tox, int groupnumber) * * return -1 on failure. */ -int tox_group_copy_names(Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t length) +int tox_group_get_names(Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t length) { Messenger *m = tox; return group_names(m, groupnumber, names, length); @@ -527,7 +527,7 @@ uint32_t tox_count_chatlist(Tox *tox) * Otherwise, returns the number of elements copied. * If the array was too small, the contents * of out_list will be truncated to list_size. */ -uint32_t tox_copy_chatlist(Tox *tox, int *out_list, uint32_t list_size) +uint32_t tox_get_chatlist(Tox *tox, int *out_list, uint32_t list_size) { Messenger *m = tox; return copy_chatlist(m, out_list, list_size); @@ -541,7 +541,7 @@ uint32_t tox_copy_chatlist(Tox *tox, int *out_list, uint32_t list_size) * * Function(Tox *tox, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) */ -void tox_callback_file_sendrequest(Tox *tox, void (*function)(Messenger *tox, int, uint8_t, uint64_t, uint8_t *, +void tox_callback_file_send_request(Tox *tox, void (*function)(Messenger *tox, int, uint8_t, uint64_t, uint8_t *, uint16_t, void *), void *userdata) { @@ -577,7 +577,7 @@ void tox_callback_file_data(Tox *tox, void (*function)(Messenger *tox, int, uint * return file number on success * return -1 on failure */ -int tox_new_filesender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length) +int tox_new_file_sender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length) { Messenger *m = tox; return new_filesender(m, friendnumber, filesize, filename, filename_length); @@ -588,7 +588,7 @@ int tox_new_filesender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *f * return 0 on success * return -1 on failure */ -int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, +int tox_file_send_control(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, uint8_t *data, uint16_t length) { Messenger *m = tox; @@ -599,18 +599,18 @@ int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8 * return 0 on success * return -1 on failure */ -int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length) +int tox_file_send_data(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length) { Messenger *m = tox; return file_data(m, friendnumber, filenumber, data, length); } -/* Returns the recommended/maximum size of the filedata you send with tox_file_senddata() +/* Returns the recommended/maximum size of the filedata you send with tox_file_send_data() * * return size on success * return -1 on failure (currently will never return -1) */ -int tox_filedata_size(Tox *tox, int friendnumber) +int tox_file_data_size(Tox *tox, int friendnumber) { return MAX_DATA_SIZE - crypto_box_MACBYTES - 3; } @@ -622,7 +622,7 @@ int tox_filedata_size(Tox *tox, int friendnumber) * return number of bytes remaining to be sent/received on success * return 0 on failure */ -uint64_t tox_file_dataremaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive) +uint64_t tox_file_data_remaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive) { Messenger *m = tox; return file_dataremaining(m, friendnumber, filenumber, send_receive); diff --git a/toxcore/tox.h b/toxcore/tox.h index ea373488..b24374a9 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -129,7 +129,7 @@ typedef struct Tox Tox; /* return FRIEND_ADDRESS_SIZE byte address to give to others. * format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] */ -void tox_getaddress(Tox *tox, uint8_t *address); +void tox_add_address(Tox *tox, uint8_t *address); /* Add a friend. * Set the data that will be sent along with friend request. @@ -147,28 +147,28 @@ void tox_getaddress(Tox *tox, uint8_t *address); * (the nospam for that friend was set to the new one). * return TOX_FAERR_NOMEM if increasing the friend list size fails. */ -int tox_addfriend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length); +int tox_add_friend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length); /* Add a friend without sending a friendrequest. * return the friend number if success. * return -1 if failure. */ -int tox_addfriend_norequest(Tox *tox, uint8_t *client_id); +int tox_add_friend_norequest(Tox *tox, uint8_t *client_id); /* return the friend id associated to that client id. return -1 if no such friend */ -int tox_getfriend_id(Tox *tox, uint8_t *client_id); +int tox_get_friend_id(Tox *tox, uint8_t *client_id); /* Copies the public key associated to that friend id into client_id buffer. * Make sure that client_id is of size CLIENT_ID_SIZE. * return 0 if success. * return -1 if failure. */ -int tox_getclient_id(Tox *tox, int friend_id, uint8_t *client_id); +int tox_get_client_id(Tox *tox, int friend_id, uint8_t *client_id); /* Remove a friend. */ -int tox_delfriend(Tox *tox, int friendnumber); +int tox_del_friend(Tox *tox, int friendnumber); /* Checks friend's connecting status. * @@ -176,7 +176,7 @@ int tox_delfriend(Tox *tox, int friendnumber); * return 0 if friend is not connected to us (Offline). * return -1 on failure. */ -int tox_get_friend_connectionstatus(Tox *tox, int friendnumber); +int tox_get_friend_connection_status(Tox *tox, int friendnumber); /* Checks if there exists a friend with given friendnumber. * @@ -195,8 +195,8 @@ int tox_friend_exists(Tox *tox, int friendnumber); * m_sendmessage_withid will send a message with the id of your choosing, * however we can generate an id for you by calling plain m_sendmessage. */ -uint32_t tox_sendmessage(Tox *tox, int friendnumber, uint8_t *message, uint32_t length); -uint32_t tox_sendmessage_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *message, uint32_t length); +uint32_t tox_send_message(Tox *tox, int friendnumber, uint8_t *message, uint32_t length); +uint32_t tox_send_message_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *message, uint32_t length); /* Send an action to an online friend. * @@ -208,8 +208,8 @@ uint32_t tox_sendmessage_withid(Tox *tox, int friendnumber, uint32_t theid, uint * m_sendaction_withid will send an action message with the id of your choosing, * however we can generate an id for you by calling plain m_sendaction. */ -uint32_t tox_sendaction(Tox *tox, int friendnumber, uint8_t *action, uint32_t length); -uint32_t tox_sendaction_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *action, uint32_t length); +uint32_t tox_send_action(Tox *tox, int friendnumber, uint8_t *action, uint32_t length); +uint32_t tox_send_action_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *action, uint32_t length); /* Set our nickname. * name must be a string of maximum MAX_NAME_LENGTH length. @@ -219,7 +219,7 @@ uint32_t tox_sendaction_withid(Tox *tox, int friendnumber, uint32_t theid, uint8 * return 0 if success. * return -1 if failure. */ -int tox_setname(Tox *tox, uint8_t *name, uint16_t length); +int tox_set_name(Tox *tox, uint8_t *name, uint16_t length); /* * Get your nickname. @@ -230,7 +230,7 @@ int tox_setname(Tox *tox, uint8_t *name, uint16_t length); * return length of name. * return 0 on error. */ -uint16_t tox_getselfname(Tox *tox, uint8_t *name, uint16_t nlen); +uint16_t tox_get_self_name(Tox *tox, uint8_t *name, uint16_t nlen); /* Get name of friendnumber and put it in name. * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes. @@ -238,7 +238,7 @@ uint16_t tox_getselfname(Tox *tox, uint8_t *name, uint16_t nlen); * return length of name (with the NULL terminator) if success. * return -1 if failure. */ -int tox_getname(Tox *tox, int friendnumber, uint8_t *name); +int tox_get_name(Tox *tox, int friendnumber, uint8_t *name); /* Set our user status. * You are responsible for freeing status after. @@ -246,13 +246,13 @@ int tox_getname(Tox *tox, int friendnumber, uint8_t *name); * returns 0 on success. * returns -1 on failure. */ -int tox_set_statusmessage(Tox *tox, uint8_t *status, uint16_t length); +int tox_set_status_message(Tox *tox, uint8_t *status, uint16_t length); int tox_set_userstatus(Tox *tox, TOX_USERSTATUS status); /* return the length of friendnumber's status message, including null. * Pass it into malloc */ -int tox_get_statusmessage_size(Tox *tox, int friendnumber); +int tox_get_status_message_size(Tox *tox, int friendnumber); /* Copy friendnumber's status message into buf, truncating if size is over maxlen. * Get the size you need to allocate from m_get_statusmessage_size. @@ -261,16 +261,16 @@ int tox_get_statusmessage_size(Tox *tox, int friendnumber); * returns the length of the copied data on success * retruns -1 on failure. */ -int tox_copy_statusmessage(Tox *tox, int friendnumber, uint8_t *buf, uint32_t maxlen); -int tox_copy_self_statusmessage(Tox *tox, uint8_t *buf, uint32_t maxlen); +int tox_get_status_message(Tox *tox, int friendnumber, uint8_t *buf, uint32_t maxlen); +int tox_get_self_status_message(Tox *tox, uint8_t *buf, uint32_t maxlen); /* return one of USERSTATUS values. * Values unknown to your application should be represented as USERSTATUS_NONE. * As above, the self variant will return our own USERSTATUS. * If friendnumber is invalid, this shall return USERSTATUS_INVALID. */ -TOX_USERSTATUS tox_get_userstatus(Tox *tox, int friendnumber); -TOX_USERSTATUS tox_get_selfuserstatus(Tox *tox); +TOX_USERSTATUS tox_get_user_status(Tox *tox, int friendnumber); +TOX_USERSTATUS tox_get_self_user_status(Tox *tox); /* Sets whether we send read receipts for friendnumber. * This function is not lazy, and it will fail if yesno is not (0 or 1). @@ -287,17 +287,17 @@ uint32_t tox_count_friendlist(Tox *tox); * Otherwise, returns the number of elements copied. * If the array was too small, the contents * of out_list will be truncated to list_size. */ -uint32_t tox_copy_friendlist(Tox *tox, int *out_list, uint32_t list_size); +uint32_t tox_get_friendlist(Tox *tox, int *out_list, uint32_t list_size); /* Set the function that will be executed when a friend request is received. * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */ -void tox_callback_friendrequest(Tox *tox, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata); +void tox_callback_friend_request(Tox *tox, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata); /* Set the function that will be executed when a message from a friend is received. * Function format is: function(int friendnumber, uint8_t * message, uint32_t length) */ -void tox_callback_friendmessage(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, uint16_t, void *), +void tox_callback_friend_message(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, uint16_t, void *), void *userdata); /* Set the function that will be executed when an action from a friend is received. @@ -309,20 +309,20 @@ void tox_callback_action(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, ui * function(int friendnumber, uint8_t *newname, uint16_t length) * You are not responsible for freeing newname */ -void tox_callback_namechange(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, uint16_t, void *), +void tox_callback_name_change(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, uint16_t, void *), void *userdata); /* Set the callback for status message changes. * function(int friendnumber, uint8_t *newstatus, uint16_t length) * You are not responsible for freeing newstatus. */ -void tox_callback_statusmessage(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, uint16_t, void *), +void tox_callback_status_message(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, uint16_t, void *), void *userdata); /* Set the callback for status type changes. * function(int friendnumber, USERSTATUS kind) */ -void tox_callback_userstatus(Tox *tox, void (*function)(Tox *tox, int, TOX_USERSTATUS, void *), void *userdata); +void tox_callback_user_status(Tox *tox, void (*function)(Tox *tox, int, TOX_USERSTATUS, void *), void *userdata); /* Set the callback for read receipts. * function(int friendnumber, uint32_t receipt) @@ -346,7 +346,7 @@ void tox_callback_read_receipt(Tox *tox, void (*function)(Tox *tox, int, uint32_ * being previously online" part. it's assumed that when adding friends, * their connection status is offline. */ -void tox_callback_connectionstatus(Tox *tox, void (*function)(Tox *tox, int, uint8_t, void *), void *userdata); +void tox_callback_connection_status(Tox *tox, void (*function)(Tox *tox, int, uint8_t, void *), void *userdata); /**********GROUP CHAT FUNCTIONS: WARNING WILL BREAK A LOT************/ @@ -374,7 +374,7 @@ typedef enum { TOX_CHAT_CHANGE_PEER_NAME, } TOX_CHAT_CHANGE; -void tox_callback_group_namelistchange(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t, void *), void *userdata); +void tox_callback_group_namelist_change(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t, void *), void *userdata); /* Creates a new groupchat and puts it in the chats array. * @@ -430,7 +430,7 @@ int tox_group_number_peers(Tox *tox, int groupnumber); * * return -1 on failure. */ -int tox_group_copy_names(Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t length); +int tox_group_get_names(Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t length); /* Return the number of chats in the instance m. * You should use this to determine how much memory to allocate @@ -442,26 +442,26 @@ uint32_t tox_count_chatlist(Tox *tox); * Otherwise, returns the number of elements copied. * If the array was too small, the contents * of out_list will be truncated to list_size. */ -uint32_t tox_copy_chatlist(Tox *tox, int *out_list, uint32_t list_size); +uint32_t tox_get_chatlist(Tox *tox, int *out_list, uint32_t list_size); /****************FILE SENDING FUNCTIONS*****************/ /* NOTE: This how to will be updated. * * HOW TO SEND FILES CORRECTLY: - * 1. Use tox_new_filesender(...) to create a new file sender. + * 1. Use tox_new_file_sender(...) to create a new file sender. * 2. Wait for the callback set with tox_callback_file_control(...) to be called with receive_send == 1 and control_type == TOX_FILECONTROL_ACCEPT - * 3. Send the data with tox_file_senddata(...) with chunk size tox_filedata_size(...) - * 4. When sending is done, send a tox_file_sendcontrol(...) with send_receive = 0 and message_id = TOX_FILECONTROL_FINISHED + * 3. Send the data with tox_file_send_data(...) with chunk size tox_file_data_size(...) + * 4. When sending is done, send a tox_file_send_control(...) with send_receive = 0 and message_id = TOX_FILECONTROL_FINISHED * * HOW TO RECEIVE FILES CORRECTLY: - * 1. wait for the callback set with tox_callback_file_sendrequest(...) - * 2. accept or refuse the connection with tox_file_sendcontrol(...) with send_receive = 1 and message_id = TOX_FILECONTROL_ACCEPT or TOX_FILECONTROL_KILL + * 1. wait for the callback set with tox_callback_file_send_request(...) + * 2. accept or refuse the connection with tox_file_send_control(...) with send_receive = 1 and message_id = TOX_FILECONTROL_ACCEPT or TOX_FILECONTROL_KILL * 3. save all the data received with the callback set with tox_callback_file_data(...) to a file. * 4. when the callback set with tox_callback_file_control(...) is called with receive_send == 0 and control_type == TOX_FILECONTROL_FINISHED * the file is done transferring. * - * tox_file_dataremaining(...) can be used to know how many bytes are left to send/receive. + * tox_file_data_remaining(...) can be used to know how many bytes are left to send/receive. * * If the connection breaks during file sending (The other person goes offline without pausing the sending and then comes back) * the reciever must send a control packet with receive_send == 0 message_id = TOX_FILECONTROL_RESUME_BROKEN and the data being @@ -484,7 +484,7 @@ enum { * * Function(Tox *tox, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) */ -void tox_callback_file_sendrequest(Tox *tox, void (*function)(Tox *m, int, uint8_t, uint64_t, uint8_t *, uint16_t, +void tox_callback_file_send_request(Tox *tox, void (*function)(Tox *m, int, uint8_t, uint64_t, uint8_t *, uint16_t, void *), void *userdata); /* Set the callback for file control requests. @@ -512,7 +512,7 @@ void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int, uint8_t, uin * return file number on success * return -1 on failure */ -int tox_new_filesender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length); +int tox_new_file_sender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length); /* Send a file control request. * @@ -522,7 +522,7 @@ int tox_new_filesender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *f * return 0 on success * return -1 on failure */ -int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, +int tox_file_send_control(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, uint8_t *data, uint16_t length); /* Send file data. @@ -530,14 +530,14 @@ int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8 * return 0 on success * return -1 on failure */ -int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length); +int tox_file_send_data(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length); -/* Returns the recommended/maximum size of the filedata you send with tox_file_senddata() +/* Returns the recommended/maximum size of the filedata you send with tox_file_send_data() * * return size on success * return -1 on failure (currently will never return -1) */ -int tox_filedata_size(Tox *tox, int friendnumber); +int tox_file_data_size(Tox *tox, int friendnumber); /* Give the number of bytes left to be sent/received. * @@ -546,7 +546,7 @@ int tox_filedata_size(Tox *tox, int friendnumber); * return number of bytes remaining to be sent/received on success * return 0 on failure */ -uint64_t tox_file_dataremaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive); +uint64_t tox_file_data_remaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive); /***************END OF FILE SENDING FUNCTIONS******************/ -- cgit v1.2.3 From 2cb7f241325684a98acf33ffba539f859ea2247c Mon Sep 17 00:00:00 2001 From: AZ Huang Date: Fri, 29 Nov 2013 23:38:06 +0800 Subject: Fix typo. --- testing/nTox.c | 2 +- testing/tox_sync.c | 2 +- toxcore/tox.c | 2 +- toxcore/tox.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'toxcore/tox.c') diff --git a/testing/nTox.c b/testing/nTox.c index acd7d971..02b93d6f 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -270,7 +270,7 @@ void get_id(Tox *m, char *data) sprintf(data, "[i] ID: "); int offset = strlen(data); uint8_t address[TOX_FRIEND_ADDRESS_SIZE]; - tox_add_address(m, address); + tox_get_address(m, address); fraddr_to_str(address, data + offset); } diff --git a/testing/tox_sync.c b/testing/tox_sync.c index ce5d9578..c00189aa 100644 --- a/testing/tox_sync.c +++ b/testing/tox_sync.c @@ -228,7 +228,7 @@ int main(int argc, char *argv[]) } uint8_t address[TOX_FRIEND_ADDRESS_SIZE]; - tox_add_address(tox, address); + tox_get_address(tox, address); uint32_t i; for (i = 0; i < TOX_FRIEND_ADDRESS_SIZE; i++) { diff --git a/toxcore/tox.c b/toxcore/tox.c index 2066b685..bdc110e6 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -37,7 +37,7 @@ typedef struct Messenger Tox; * Format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] * */ -void tox_add_address(Tox *tox, uint8_t *address) +void tox_get_address(Tox *tox, uint8_t *address) { Messenger *m = tox; getaddress(m, address); diff --git a/toxcore/tox.h b/toxcore/tox.h index b24374a9..407d7441 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -129,7 +129,7 @@ typedef struct Tox Tox; /* return FRIEND_ADDRESS_SIZE byte address to give to others. * format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] */ -void tox_add_address(Tox *tox, uint8_t *address); +void tox_get_address(Tox *tox, uint8_t *address); /* Add a friend. * Set the data that will be sent along with friend request. -- cgit v1.2.3 From 3f2d815fab4b7f72d9bce7273ecfe823464f304c Mon Sep 17 00:00:00 2001 From: alexandervdm Date: Tue, 3 Dec 2013 14:54:46 +0100 Subject: fix naming inconsistency in tox.h --- toxcore/tox.c | 2 +- toxcore/tox.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'toxcore/tox.c') diff --git a/toxcore/tox.c b/toxcore/tox.c index bdc110e6..487f2517 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -222,7 +222,7 @@ int tox_set_status_message(Tox *tox, uint8_t *status, uint16_t length) return m_set_statusmessage(m, status, length); } -int tox_set_userstatus(Tox *tox, TOX_USERSTATUS status) +int tox_set_user_status(Tox *tox, TOX_USERSTATUS status) { Messenger *m = tox; return m_set_userstatus(m, (USERSTATUS)status); diff --git a/toxcore/tox.h b/toxcore/tox.h index 407d7441..ccef8519 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -247,7 +247,7 @@ int tox_get_name(Tox *tox, int friendnumber, uint8_t *name); * returns -1 on failure. */ int tox_set_status_message(Tox *tox, uint8_t *status, uint16_t length); -int tox_set_userstatus(Tox *tox, TOX_USERSTATUS status); +int tox_set_user_status(Tox *tox, TOX_USERSTATUS status); /* return the length of friendnumber's status message, including null. * Pass it into malloc -- cgit v1.2.3