mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 21:33:02 +01:00
fix on_friendadded()
This commit is contained in:
parent
e091b36b14
commit
8bbd796755
@ -97,10 +97,10 @@ static void friendlist_onStatusMessageChange(ToxWindow *self, int num, uint8_t *
|
||||
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)
|
||||
return -1;
|
||||
return;
|
||||
|
||||
int i;
|
||||
|
||||
@ -128,11 +128,9 @@ int friendlist_onFriendAdded(Tox *m, int num)
|
||||
++max_friends_index;
|
||||
|
||||
sort_friendlist_index();
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
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.onDraw = &friendlist_onDraw;
|
||||
ret.onInit = &friendlist_onInit;
|
||||
ret.onFriendAdded = &friendlist_onFriendAdded;
|
||||
ret.onMessage = &friendlist_onMessage;
|
||||
ret.onConnectionChange = &friendlist_onConnectionChange;
|
||||
ret.onAction = &friendlist_onMessage; // Action has identical behaviour to message
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "chat.h"
|
||||
|
||||
ToxWindow new_friendlist();
|
||||
int friendlist_onFriendAdded(Tox *m, int num);
|
||||
void disable_chatwin(int f_num);
|
||||
int get_friendnum(uint8_t *name);
|
||||
|
||||
|
@ -264,7 +264,7 @@ void cmd_prompt_help(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int arg
|
||||
{
|
||||
wclear(window);
|
||||
wattron(window, COLOR_PAIR(CYAN) | A_BOLD);
|
||||
wprintw(window, "\n\nCommands:\n");
|
||||
wprintw(window, "\n\nGlobal commands:\n");
|
||||
wattroff(window, A_BOLD);
|
||||
|
||||
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, " /quit or /exit : Exit Toxic\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);
|
||||
wprintw(window, " * Argument messages must be enclosed in quotation marks.\n");
|
||||
|
@ -50,6 +50,7 @@ struct ToxWindow_ {
|
||||
void(*onDraw)(ToxWindow *, Tox *);
|
||||
void(*onInit)(ToxWindow *, Tox *);
|
||||
void(*onFriendRequest)(ToxWindow *, uint8_t *, uint8_t *, uint16_t);
|
||||
void(*onFriendAdded)(ToxWindow *, Tox *, int);
|
||||
void(*onConnectionChange)(ToxWindow *, Tox *, int, uint8_t);
|
||||
void(*onMessage)(ToxWindow *, Tox *, int, uint8_t *, uint16_t);
|
||||
void(*onNickChange)(ToxWindow *, int, uint8_t *, uint16_t);
|
||||
|
@ -95,7 +95,12 @@ void on_statuschange(Tox *m, int friendnumber, TOX_USERSTATUS status, void *user
|
||||
|
||||
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))
|
||||
wprintw(prompt->window, "\nCould not store Tox data\n");
|
||||
|
Loading…
Reference in New Issue
Block a user