From 2db69f0fd60ae476df7bebaaebc604c10c48d8a2 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sat, 24 Aug 2013 00:21:01 +0200 Subject: [PATCH] Use tox_ instead of m_ functions --- src/chat.c | 18 ++++++++---------- src/friendlist.c | 2 +- src/main.c | 18 +++++++++--------- src/prompt.c | 12 ++++++------ 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/chat.c b/src/chat.c index 9490233..8e4ae66 100644 --- a/src/chat.c +++ b/src/chat.c @@ -13,8 +13,6 @@ #include #include -#include "network.h" - #include "toxic_windows.h" #include "friendlist.h" #include "chat.h" @@ -50,7 +48,7 @@ static void chat_onMessage(ToxWindow *self, Tox *m, int num, uint8_t *msg, uint1 if (ctx->friendnum != num) return; - getname(m, num, (uint8_t *) &nick); + tox_getname(m, num, (uint8_t *) &nick); msg[len - 1] = '\0'; nick[TOX_MAX_NAME_LENGTH - 1] = '\0'; @@ -232,7 +230,7 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key) wattroff(ctx->history, COLOR_PAIR(1)); wprintw(ctx->history, "%s\n", line); - if (m_sendmessage(m, ctx->friendnum, (uint8_t *) line, strlen(line) + 1) == 0) { + if (tox_sendmessage(m, ctx->friendnum, (uint8_t *) line, strlen(line) + 1) == 0) { wattron(ctx->history, COLOR_PAIR(3)); wprintw(ctx->history, " * Failed to send message.\n"); wattroff(ctx->history, COLOR_PAIR(3)); @@ -289,7 +287,7 @@ void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd) wprintw(ctx->history, msg); wattroff(ctx->history, COLOR_PAIR(5)); - if (m_sendaction(m, ctx->friendnum, (uint8_t *) msg, strlen(msg) + 1) < 0) { + if (tox_sendaction(m, ctx->friendnum, (uint8_t *) msg, strlen(msg) + 1) < 0) { wattron(ctx->history, COLOR_PAIR(3)); wprintw(ctx->history, " * Failed to send action\n"); wattroff(ctx->history, COLOR_PAIR(3)); @@ -332,12 +330,12 @@ void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd) msg = strchr(status, ' '); if (msg == NULL) { - m_set_userstatus(m, status_kind); + tox_set_userstatus(m, status_kind); wprintw(ctx->history, "Status set to: %s\n", status_text); } else { msg++; - m_set_userstatus(m, status_kind); - m_set_statusmessage(m, ( uint8_t *) msg, strlen(msg) + 1); + tox_set_userstatus(m, status_kind); + tox_set_statusmessage(m, ( uint8_t *) msg, strlen(msg) + 1); wprintw(ctx->history, "Status set to: %s, %s\n", status_text, msg); } } @@ -352,7 +350,7 @@ void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd) } nick++; - setname(m, (uint8_t *) nick, strlen(nick) + 1); + tox_setname(m, (uint8_t *) nick, strlen(nick) + 1); wprintw(ctx->history, "Nickname set to: %s\n", nick); } @@ -437,7 +435,7 @@ ToxWindow new_chat(Tox *m, int friendnum) ret.onAction = &chat_onAction; uint8_t nick[TOX_MAX_NAME_LENGTH] = {0}; - getname(m, friendnum, (uint8_t *) &nick); + tox_getname(m, friendnum, (uint8_t *) &nick); snprintf(ret.title, sizeof(ret.title), "[%s (%d)]", nick, friendnum); diff --git a/src/friendlist.c b/src/friendlist.c index ec6d970..b198656 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -61,7 +61,7 @@ int friendlist_onFriendAdded(Tox *m, int num) return -1; friends[num_friends].num = num; - getname(m, num, friends[num_friends].name); + tox_getname(m, num, friends[num_friends].name); strcpy((char *) friends[num_friends].name, "unknown"); strcpy((char *) friends[num_friends].status, "unknown"); friends[num_friends++].chatwin = -1; diff --git a/src/main.c b/src/main.c index a63411e..390099a 100644 --- a/src/main.c +++ b/src/main.c @@ -76,19 +76,19 @@ static Tox *init_tox() Tox *m = tox_new(); /* Callbacks */ - m_callback_friendrequest(m, on_request, NULL); - m_callback_friendmessage(m, on_message, NULL); - m_callback_namechange(m, on_nickchange, NULL); - m_callback_statusmessage(m, on_statuschange, NULL); - m_callback_action(m, on_action, NULL); + tox_callback_friendrequest(m, on_request, NULL); + tox_callback_friendmessage(m, on_message, NULL); + tox_callback_namechange(m, on_nickchange, NULL); + tox_callback_statusmessage(m, on_statuschange, NULL); + tox_callback_action(m, on_action, NULL); #ifdef __linux__ - setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy")); + tox_setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy")); #elif defined(WIN32) - setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux")); + tox_setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux")); #elif defined(__APPLE__) - setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters + tox_setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters #else - setname(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4")); + tox_setname(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4")); #endif return m; } diff --git a/src/prompt.c b/src/prompt.c index 50e0d4c..94dbe52 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -244,7 +244,7 @@ void cmd_msg(ToxWindow *self, Tox *m, char **args) char *id = args[1]; char *msg = args[2]; - if (m_sendmessage(m, atoi(id), (uint8_t *) msg, strlen(msg) + 1) == 0) + if (tox_sendmessage(m, atoi(id), (uint8_t *) msg, strlen(msg) + 1) == 0) wprintw(self->window, "Error occurred while sending message.\n"); else wprintw(self->window, "Message successfully sent.\n"); @@ -269,7 +269,7 @@ void cmd_myid(ToxWindow *self, Tox *m, char **args) void cmd_nick(ToxWindow *self, Tox *m, char **args) { char *nick = args[1]; - setname(m, (uint8_t *) nick, strlen(nick) + 1); + tox_setname(m, (uint8_t *) nick, strlen(nick) + 1); wprintw(self->window, "Nickname set to: %s\n", nick); if (store_data(m, DATA_FILE)) { @@ -309,11 +309,11 @@ void cmd_status(ToxWindow *self, Tox *m, char **args) char *msg = args[2]; if (msg == NULL) { - m_set_userstatus(m, status_kind); + tox_set_userstatus(m, status_kind); wprintw(self->window, "Status set to: %s\n", status_text); } else { - m_set_userstatus(m, status_kind); - m_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1); + tox_set_userstatus(m, status_kind); + tox_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1); wprintw(self->window, "Status set to: %s, %s\n", status_text, msg); } } @@ -321,7 +321,7 @@ void cmd_status(ToxWindow *self, Tox *m, char **args) void cmd_statusmsg(ToxWindow *self, Tox *m, char **args) { char *msg = args[1]; - m_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1); + tox_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1); wprintw(self->window, "Status set to: %s\n", msg); }