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

fix on_friendadded()

This commit is contained in:
Jfreegman 2013-11-15 14:59:49 -05:00
parent e091b36b14
commit 8bbd796755
5 changed files with 13 additions and 9 deletions

View File

@ -97,10 +97,10 @@ static void friendlist_onStatusMessageChange(ToxWindow *self, int num, uint8_t *
friends[num].statusmsg_len = len; friends[num].statusmsg_len = len;
} }
int friendlist_onFriendAdded(Tox *m, int num) static void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int num)
{ {
if (max_friends_index < 0 || max_friends_index >= MAX_FRIENDS_NUM) if (max_friends_index < 0 || max_friends_index >= MAX_FRIENDS_NUM)
return -1; return;
int i; int i;
@ -128,11 +128,9 @@ int friendlist_onFriendAdded(Tox *m, int num)
++max_friends_index; ++max_friends_index;
sort_friendlist_index(); sort_friendlist_index();
return 0; return;
} }
} }
return -1;
} }
static void friendlist_onFileSendRequest(ToxWindow *self, Tox *m, int num, uint8_t filenum, static void friendlist_onFileSendRequest(ToxWindow *self, Tox *m, int num, uint8_t filenum,
@ -300,6 +298,7 @@ ToxWindow new_friendlist(void)
ret.onKey = &friendlist_onKey; ret.onKey = &friendlist_onKey;
ret.onDraw = &friendlist_onDraw; ret.onDraw = &friendlist_onDraw;
ret.onInit = &friendlist_onInit; ret.onInit = &friendlist_onInit;
ret.onFriendAdded = &friendlist_onFriendAdded;
ret.onMessage = &friendlist_onMessage; ret.onMessage = &friendlist_onMessage;
ret.onConnectionChange = &friendlist_onConnectionChange; ret.onConnectionChange = &friendlist_onConnectionChange;
ret.onAction = &friendlist_onMessage; // Action has identical behaviour to message ret.onAction = &friendlist_onMessage; // Action has identical behaviour to message

View File

@ -5,7 +5,6 @@
#include "chat.h" #include "chat.h"
ToxWindow new_friendlist(); ToxWindow new_friendlist();
int friendlist_onFriendAdded(Tox *m, int num);
void disable_chatwin(int f_num); void disable_chatwin(int f_num);
int get_friendnum(uint8_t *name); int get_friendnum(uint8_t *name);

View File

@ -264,7 +264,7 @@ void cmd_prompt_help(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int arg
{ {
wclear(window); wclear(window);
wattron(window, COLOR_PAIR(CYAN) | A_BOLD); wattron(window, COLOR_PAIR(CYAN) | A_BOLD);
wprintw(window, "\n\nCommands:\n"); wprintw(window, "\n\nGlobal commands:\n");
wattroff(window, A_BOLD); wattroff(window, A_BOLD);
wprintw(window, " /add <id> <message> : Add friend with optional message\n"); wprintw(window, " /add <id> <message> : Add friend with optional message\n");
@ -277,7 +277,7 @@ void cmd_prompt_help(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int arg
wprintw(window, " /myid : Print your ID\n"); wprintw(window, " /myid : Print your ID\n");
wprintw(window, " /quit or /exit : Exit Toxic\n"); wprintw(window, " /quit or /exit : Exit Toxic\n");
wprintw(window, " /help : Print this message again\n"); wprintw(window, " /help : Print this message again\n");
wprintw(window, " /clear : Clear this window\n"); wprintw(window, " /clear : Clear the window\n");
wattron(window, A_BOLD); wattron(window, A_BOLD);
wprintw(window, " * Argument messages must be enclosed in quotation marks.\n"); wprintw(window, " * Argument messages must be enclosed in quotation marks.\n");

View File

@ -50,6 +50,7 @@ struct ToxWindow_ {
void(*onDraw)(ToxWindow *, Tox *); void(*onDraw)(ToxWindow *, Tox *);
void(*onInit)(ToxWindow *, Tox *); void(*onInit)(ToxWindow *, Tox *);
void(*onFriendRequest)(ToxWindow *, uint8_t *, uint8_t *, uint16_t); void(*onFriendRequest)(ToxWindow *, uint8_t *, uint8_t *, uint16_t);
void(*onFriendAdded)(ToxWindow *, Tox *, int);
void(*onConnectionChange)(ToxWindow *, Tox *, int, uint8_t); void(*onConnectionChange)(ToxWindow *, Tox *, int, uint8_t);
void(*onMessage)(ToxWindow *, Tox *, int, uint8_t *, uint16_t); void(*onMessage)(ToxWindow *, Tox *, int, uint8_t *, uint16_t);
void(*onNickChange)(ToxWindow *, int, uint8_t *, uint16_t); void(*onNickChange)(ToxWindow *, int, uint8_t *, uint16_t);

View File

@ -95,7 +95,12 @@ void on_statuschange(Tox *m, int friendnumber, TOX_USERSTATUS status, void *user
void on_friendadded(Tox *m, int friendnumber) void on_friendadded(Tox *m, int friendnumber)
{ {
friendlist_onFriendAdded(m, friendnumber); int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onFriendAdded != NULL)
windows[i].onFriendAdded(&windows[i], m, friendnumber);
}
if (store_data(m, DATA_FILE)) if (store_data(m, DATA_FILE))
wprintw(prompt->window, "\nCould not store Tox data\n"); wprintw(prompt->window, "\nCould not store Tox data\n");