Fix API name consistency.

This commit is contained in:
AZ Huang 2013-11-29 23:12:07 +08:00
parent 6e691a3c34
commit 8419d3469a
4 changed files with 118 additions and 118 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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);

View File

@ -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******************/