1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 01:53:02 +01:00

Merge pull request #58 from aitjcize/api-name

Fix corresponding API name changes in toxcore.
This commit is contained in:
irungentoo 2013-11-29 08:26:53 -08:00
commit e4e7ed7e4e
7 changed files with 49 additions and 49 deletions

View File

@ -26,7 +26,7 @@ static void chat_onMessage(ToxWindow *self, Tox *m, int num, uint8_t *msg, uint1
ChatContext *ctx = (ChatContext *) self->chatwin;
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
tox_getname(m, num, nick);
tox_get_name(m, num, nick);
nick[TOXIC_MAX_NAME_LENGTH] = '\0';
print_time(ctx->history);
@ -61,7 +61,7 @@ static void chat_onAction(ToxWindow *self, Tox *m, int num, uint8_t *action, uin
ChatContext *ctx = (ChatContext *) self->chatwin;
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
tox_getname(m, num, nick);
tox_get_name(m, num, nick);
nick[TOXIC_MAX_NAME_LENGTH] = '\0';
print_time(ctx->history);
@ -230,7 +230,7 @@ static void chat_onGroupInvite(ToxWindow *self, Tox *m, int friendnumber, uint8_
ChatContext *ctx = (ChatContext *) self->chatwin;
uint8_t name[TOX_MAX_NAME_LENGTH] = {'\0'};
if (tox_getname(m, friendnumber, name) == -1)
if (tox_get_name(m, friendnumber, name) == -1)
return;
wprintw(ctx->history, "%s has invited you to a group chat.\n", name);
@ -252,14 +252,14 @@ static void send_action(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t *acti
}
uint8_t selfname[TOX_MAX_NAME_LENGTH];
tox_getselfname(m, selfname, TOX_MAX_NAME_LENGTH);
tox_get_self_name(m, selfname, TOX_MAX_NAME_LENGTH);
print_time(ctx->history);
wattron(ctx->history, COLOR_PAIR(YELLOW));
wprintw(ctx->history, "* %s %s\n", selfname, action);
wattroff(ctx->history, COLOR_PAIR(YELLOW));
if (tox_sendaction(m, self->num, action, strlen(action) + 1) == 0) {
if (tox_send_action(m, self->num, action, strlen(action) + 1) == 0) {
wattron(ctx->history, COLOR_PAIR(RED));
wprintw(ctx->history, " * Failed to send action\n");
wattroff(ctx->history, COLOR_PAIR(RED));
@ -322,7 +322,7 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
/* make sure the string has at least non-space character */
if (!string_is_empty(line)) {
uint8_t selfname[TOX_MAX_NAME_LENGTH];
tox_getselfname(m, selfname, TOX_MAX_NAME_LENGTH);
tox_get_self_name(m, selfname, TOX_MAX_NAME_LENGTH);
print_time(ctx->history);
wattron(ctx->history, COLOR_PAIR(GREEN));
@ -337,7 +337,7 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
wprintw(ctx->history, "%s\n", line);
if (!statusbar->is_online
|| tox_sendmessage(m, self->num, line, strlen(line) + 1) == 0) {
|| tox_send_message(m, self->num, line, strlen(line) + 1) == 0) {
wattron(ctx->history, COLOR_PAIR(RED));
wprintw(ctx->history, " * Failed to send message.\n");
wattroff(ctx->history, COLOR_PAIR(RED));
@ -408,9 +408,9 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
/* Reset statusbar->statusmsg on window resize */
if (x != self->x) {
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH] = {'\0'};
tox_copy_statusmessage(m, self->num, statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
tox_get_status_message(m, self->num, statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
snprintf(statusbar->statusmsg, sizeof(statusbar->statusmsg), "%s", statusmsg);
statusbar->statusmsg_len = tox_get_statusmessage_size(m, self->num);
statusbar->statusmsg_len = tox_get_status_message_size(m, self->num);
}
self->x = x;
@ -442,13 +442,13 @@ static void chat_onInit(ToxWindow *self, Tox *m)
/* Init statusbar info */
StatusBar *statusbar = (StatusBar *) self->stb;
statusbar->status = tox_get_userstatus(m, self->num);
statusbar->is_online = tox_get_friend_connectionstatus(m, self->num) == 1;
statusbar->status = tox_get_user_status(m, self->num);
statusbar->is_online = tox_get_friend_connection_status(m, self->num) == 1;
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH] = {'\0'};
tox_copy_statusmessage(m, self->num, statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
tox_get_status_message(m, self->num, statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
snprintf(statusbar->statusmsg, sizeof(statusbar->statusmsg), "%s", statusmsg);
statusbar->statusmsg_len = tox_get_statusmessage_size(m, self->num);
statusbar->statusmsg_len = tox_get_status_message_size(m, self->num);
/* Init subwindows */
ChatContext *ctx = (ChatContext *) self->chatwin;
@ -481,7 +481,7 @@ ToxWindow new_chat(Tox *m, int friendnum)
ret.onFileData = &chat_onFileData;
uint8_t name[TOX_MAX_NAME_LENGTH] = {'\0'};
uint16_t len = tox_getname(m, friendnum, name);
uint16_t len = tox_get_name(m, friendnum, name);
memcpy(ret.name, name, len);
ret.name[TOXIC_MAX_NAME_LENGTH] = '\0';

View File

@ -113,7 +113,7 @@ void cmd_savefile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
uint8_t *filename = friends[self->num].file_receiver.filenames[filenum];
if (tox_file_sendcontrol(m, self->num, 1, filenum, TOX_FILECONTROL_ACCEPT, 0, 0) == 0)
if (tox_file_send_control(m, self->num, 1, filenum, TOX_FILECONTROL_ACCEPT, 0, 0) == 0)
wprintw(window, "Accepted file transfer %u. Saving file as: '%s'\n", filenum, filename);
else
wprintw(window, "File transfer failed.\n");
@ -159,7 +159,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
uint64_t filesize = ftell(file_to_send);
fseek(file_to_send, 0, SEEK_SET);
int filenum = tox_new_filesender(m, self->num, filesize, path, path_len + 1);
int filenum = tox_new_file_sender(m, self->num, filesize, path, path_len + 1);
if (filenum == -1) {
wprintw(window, "Error sending file.\n");
@ -178,7 +178,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
file_senders[i].friendnum = self->num;
file_senders[i].timestamp = (uint64_t) time(NULL);
file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1,
tox_filedata_size(m, self->num), file_to_send);
tox_file_data_size(m, self->num), file_to_send);
wprintw(window, "Sending file: '%s'\n", path);

View File

@ -112,7 +112,7 @@ static void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int num)
friends[i].chatwin = -1;
friends[i].online = false;
friends[i].status = TOX_USERSTATUS_NONE;
friends[i].namelength = tox_getname(m, num, friends[i].name);
friends[i].namelength = tox_get_name(m, num, friends[i].name);
if (friends[i].namelength == -1 || friends[i].name[0] == '\0') {
strcpy(friends[i].name, (uint8_t *) UNKNOWN_NAME);
@ -164,7 +164,7 @@ static void select_friend(ToxWindow *self, Tox *m, wint_t key)
static void delete_friend(Tox *m, ToxWindow *self, int f_num, wint_t key)
{
tox_delfriend(m, f_num);
tox_del_friend(m, f_num);
memset(&friends[f_num], 0, sizeof(friend_t));
int i;
@ -274,9 +274,9 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
/* Reset friends[f].statusmsg on window resize */
if (fix_statuses) {
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH] = {'\0'};
tox_copy_statusmessage(m, friends[f].num, statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
tox_get_status_message(m, friends[f].num, statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
snprintf(friends[f].statusmsg, sizeof(friends[f].statusmsg), "%s", statusmsg);
friends[f].statusmsg_len = tox_get_statusmessage_size(m, f);
friends[f].statusmsg_len = tox_get_status_message_size(m, f);
}
/* Truncate note if it doesn't fit on one line */

View File

@ -40,7 +40,7 @@ void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
return;
}
int friendnum = tox_addfriend_norequest(m, pending_frnd_requests[req]);
int friendnum = tox_add_friend_norequest(m, pending_frnd_requests[req]);
if (friendnum == -1)
wprintw(window, "Failed to add friend.\n");
@ -83,7 +83,7 @@ void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
snprintf(msg, sizeof(msg), "%s", temp);
} else {
uint8_t selfname[TOX_MAX_NAME_LENGTH];
tox_getselfname(m, selfname, TOX_MAX_NAME_LENGTH);
tox_get_self_name(m, selfname, TOX_MAX_NAME_LENGTH);
snprintf(msg, sizeof(msg), "Hello, my name is %s. Care to Tox?", selfname);
}
@ -114,7 +114,7 @@ void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
id[i] = toupper(id[i]);
}
int f_num = tox_addfriend(m, id_bin, msg, strlen(msg) + 1);
int f_num = tox_add_friend(m, id_bin, msg, strlen(msg) + 1);
switch (f_num) {
case TOX_FAERR_TOOLONG:
@ -202,7 +202,7 @@ void cmd_myid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
{
char id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1] = {0};
uint8_t address[TOX_FRIEND_ADDRESS_SIZE];
tox_getaddress(m, address);
tox_get_address(m, address);
size_t i;
@ -242,7 +242,7 @@ void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
len = TOXIC_MAX_NAME_LENGTH - 1;
}
tox_setname(m, nick, len+1);
tox_set_name(m, nick, len+1);
prompt_update_nick(prompt, nick, len+1);
store_data(m, DATA_FILE);
@ -264,7 +264,7 @@ void cmd_note(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
msg[strlen(++msg)-1] = L'\0';
uint16_t len = strlen(msg) + 1;
tox_set_statusmessage(m, msg, len);
tox_set_status_message(m, msg, len);
prompt_update_statusmessage(prompt, msg, len);
}
@ -344,7 +344,7 @@ void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
if (msg != NULL) {
msg[strlen(++msg)-1] = L'\0'; /* remove opening and closing quotes */
uint16_t len = strlen(msg) + 1;
tox_set_statusmessage(m, msg, len);
tox_set_status_message(m, msg, len);
prompt_update_statusmessage(prompt, msg, len);
}
}

View File

@ -171,7 +171,7 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu
/* Update name lists */
uint8_t tmp_peerlist[num_peers][TOX_MAX_NAME_LENGTH];
tox_group_copy_names(m, groupnum, tmp_peerlist, num_peers);
tox_group_get_names(m, groupnum, tmp_peerlist, num_peers);
copy_peernames(groupnum, num_peers, tmp_peerlist);
/* get current peername then sort namelist */
@ -274,7 +274,7 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)
/* make sure the string has at least non-space character */
if (!string_is_empty(line)) {
// uint8_t selfname[TOX_MAX_NAME_LENGTH];
// tox_getselfname(m, selfname, TOX_MAX_NAME_LENGTH);
// tox_get_self_name(m, selfname, TOX_MAX_NAME_LENGTH);
// print_time(ctx->history);
// wattron(ctx->history, COLOR_PAIR(GREEN));

View File

@ -98,28 +98,28 @@ static Tox *init_tox()
return NULL;
/* Callbacks */
tox_callback_connectionstatus(m, on_connectionchange, NULL);
tox_callback_friendrequest(m, on_request, NULL);
tox_callback_friendmessage(m, on_message, NULL);
tox_callback_namechange(m, on_nickchange, NULL);
tox_callback_userstatus(m, on_statuschange, NULL);
tox_callback_statusmessage(m, on_statusmessagechange, NULL);
tox_callback_connection_status(m, on_connectionchange, NULL);
tox_callback_friend_request(m, on_request, NULL);
tox_callback_friend_message(m, on_message, NULL);
tox_callback_name_change(m, on_nickchange, NULL);
tox_callback_user_status(m, on_statuschange, NULL);
tox_callback_status_message(m, on_statusmessagechange, NULL);
tox_callback_action(m, on_action, NULL);
tox_callback_group_invite(m, on_groupinvite, NULL);
tox_callback_group_message(m, on_groupmessage, NULL);
tox_callback_group_namelistchange(m, on_group_namelistchange, NULL);
tox_callback_file_sendrequest(m, on_file_sendrequest, NULL);
tox_callback_group_namelist_change(m, on_group_namelistchange, NULL);
tox_callback_file_send_request(m, on_file_sendrequest, NULL);
tox_callback_file_control(m, on_file_control, NULL);
tox_callback_file_data(m, on_file_data, NULL);
#ifdef __linux__
tox_setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy"));
tox_set_name(m, (uint8_t *) "Cool guy", sizeof("Cool guy"));
#elif defined(_WIN32)
tox_setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux"));
tox_set_name(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux"));
#elif defined(__APPLE__)
tox_setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters
tox_set_name(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters
#else
tox_setname(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4"));
tox_set_name(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4"));
#endif
return m;
@ -331,7 +331,7 @@ static void load_data(Tox *m, char *path)
uint32_t i = 0;
uint8_t name[TOX_MAX_NAME_LENGTH];
while (tox_getname(m, i, name) != -1) {
while (tox_get_name(m, i, name) != -1) {
on_friendadded(m, i);
i++;
}
@ -387,7 +387,7 @@ static void do_file_senders(Tox *m)
alert_window(file_senders[i].toxwin, WINDOW_ALERT_2, true);
}
tox_file_sendcontrol(m, friendnum, 0, filenum, TOX_FILECONTROL_KILL, 0, 0);
tox_file_send_control(m, friendnum, 0, filenum, TOX_FILECONTROL_KILL, 0, 0);
close_file_sender(i);
continue;
}
@ -395,13 +395,13 @@ static void do_file_senders(Tox *m)
int pieces = 0;
while (pieces++ < MAX_PIECES_SEND) {
if (tox_file_senddata(m, friendnum, filenum, file_senders[i].nextpiece,
if (tox_file_send_data(m, friendnum, filenum, file_senders[i].nextpiece,
file_senders[i].piecelen) == -1)
break;
file_senders[i].timestamp = current_time;
file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1,
tox_filedata_size(m, friendnum), fp);
tox_file_data_size(m, friendnum), fp);
if (file_senders[i].piecelen == 0) {
ChatContext *ctx = (ChatContext *) file_senders[i].toxwin->chatwin;
@ -411,7 +411,7 @@ static void do_file_senders(Tox *m)
alert_window(file_senders[i].toxwin, WINDOW_ALERT_2, true);
}
tox_file_sendcontrol(m, friendnum, 0, filenum, TOX_FILECONTROL_FINISHED, 0, 0);
tox_file_send_control(m, friendnum, 0, filenum, TOX_FILECONTROL_FINISHED, 0, 0);
close_file_sender(i);
break;
}

View File

@ -191,7 +191,7 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int friendnum , u
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
if (tox_getname(m, friendnum, nick) == -1)
if (tox_get_name(m, friendnum, nick) == -1)
return;
if (!nick[0])
@ -244,7 +244,7 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m)
statusbar->is_online = false;
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
tox_getselfname(m, nick, TOX_MAX_NAME_LENGTH);
tox_get_self_name(m, nick, TOX_MAX_NAME_LENGTH);
snprintf(statusbar->nick, sizeof(statusbar->nick), "%s", nick);
/* temporary until statusmessage saving works */