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

Use tox_ instead of m_ functions

This commit is contained in:
Florian Hahn 2013-08-24 00:21:01 +02:00
parent 0f97e37fa3
commit 2db69f0fd6
4 changed files with 24 additions and 26 deletions

View File

@ -13,8 +13,6 @@
#include <time.h> #include <time.h>
#include <limits.h> #include <limits.h>
#include "network.h"
#include "toxic_windows.h" #include "toxic_windows.h"
#include "friendlist.h" #include "friendlist.h"
#include "chat.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) if (ctx->friendnum != num)
return; return;
getname(m, num, (uint8_t *) &nick); tox_getname(m, num, (uint8_t *) &nick);
msg[len - 1] = '\0'; msg[len - 1] = '\0';
nick[TOX_MAX_NAME_LENGTH - 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)); wattroff(ctx->history, COLOR_PAIR(1));
wprintw(ctx->history, "%s\n", line); 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)); wattron(ctx->history, COLOR_PAIR(3));
wprintw(ctx->history, " * Failed to send message.\n"); wprintw(ctx->history, " * Failed to send message.\n");
wattroff(ctx->history, COLOR_PAIR(3)); wattroff(ctx->history, COLOR_PAIR(3));
@ -289,7 +287,7 @@ void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd)
wprintw(ctx->history, msg); wprintw(ctx->history, msg);
wattroff(ctx->history, COLOR_PAIR(5)); 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)); wattron(ctx->history, COLOR_PAIR(3));
wprintw(ctx->history, " * Failed to send action\n"); wprintw(ctx->history, " * Failed to send action\n");
wattroff(ctx->history, COLOR_PAIR(3)); wattroff(ctx->history, COLOR_PAIR(3));
@ -332,12 +330,12 @@ void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd)
msg = strchr(status, ' '); msg = strchr(status, ' ');
if (msg == NULL) { 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); wprintw(ctx->history, "Status set to: %s\n", status_text);
} else { } else {
msg++; msg++;
m_set_userstatus(m, status_kind); tox_set_userstatus(m, status_kind);
m_set_statusmessage(m, ( uint8_t *) msg, strlen(msg) + 1); tox_set_statusmessage(m, ( uint8_t *) msg, strlen(msg) + 1);
wprintw(ctx->history, "Status set to: %s, %s\n", status_text, msg); 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++; 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); wprintw(ctx->history, "Nickname set to: %s\n", nick);
} }
@ -437,7 +435,7 @@ ToxWindow new_chat(Tox *m, int friendnum)
ret.onAction = &chat_onAction; ret.onAction = &chat_onAction;
uint8_t nick[TOX_MAX_NAME_LENGTH] = {0}; 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); snprintf(ret.title, sizeof(ret.title), "[%s (%d)]", nick, friendnum);

View File

@ -61,7 +61,7 @@ int friendlist_onFriendAdded(Tox *m, int num)
return -1; return -1;
friends[num_friends].num = num; 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].name, "unknown");
strcpy((char *) friends[num_friends].status, "unknown"); strcpy((char *) friends[num_friends].status, "unknown");
friends[num_friends++].chatwin = -1; friends[num_friends++].chatwin = -1;

View File

@ -76,19 +76,19 @@ static Tox *init_tox()
Tox *m = tox_new(); Tox *m = tox_new();
/* Callbacks */ /* Callbacks */
m_callback_friendrequest(m, on_request, NULL); tox_callback_friendrequest(m, on_request, NULL);
m_callback_friendmessage(m, on_message, NULL); tox_callback_friendmessage(m, on_message, NULL);
m_callback_namechange(m, on_nickchange, NULL); tox_callback_namechange(m, on_nickchange, NULL);
m_callback_statusmessage(m, on_statuschange, NULL); tox_callback_statusmessage(m, on_statuschange, NULL);
m_callback_action(m, on_action, NULL); tox_callback_action(m, on_action, NULL);
#ifdef __linux__ #ifdef __linux__
setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy")); tox_setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy"));
#elif defined(WIN32) #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__) #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 #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 #endif
return m; return m;
} }

View File

@ -244,7 +244,7 @@ void cmd_msg(ToxWindow *self, Tox *m, char **args)
char *id = args[1]; char *id = args[1];
char *msg = args[2]; 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"); wprintw(self->window, "Error occurred while sending message.\n");
else else
wprintw(self->window, "Message successfully sent.\n"); 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) void cmd_nick(ToxWindow *self, Tox *m, char **args)
{ {
char *nick = args[1]; 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); wprintw(self->window, "Nickname set to: %s\n", nick);
if (store_data(m, DATA_FILE)) { if (store_data(m, DATA_FILE)) {
@ -309,11 +309,11 @@ void cmd_status(ToxWindow *self, Tox *m, char **args)
char *msg = args[2]; char *msg = args[2];
if (msg == NULL) { 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); wprintw(self->window, "Status set to: %s\n", status_text);
} else { } else {
m_set_userstatus(m, status_kind); tox_set_userstatus(m, status_kind);
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, %s\n", status_text, msg); 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) void cmd_statusmsg(ToxWindow *self, Tox *m, char **args)
{ {
char *msg = args[1]; 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); wprintw(self->window, "Status set to: %s\n", msg);
} }