mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-13 02:33:03 +01:00
fixes
This commit is contained in:
parent
bde7aacc8d
commit
e6956b1abc
@ -78,7 +78,7 @@ static void chat_onNickChange(ToxWindow *self, int num, uint8_t *nick, uint16_t
|
||||
if (self->num != num)
|
||||
return;
|
||||
|
||||
snprintf(self->name, sizeof(self->name), "%s", nick);
|
||||
memcpy(self->name, nick, len);
|
||||
}
|
||||
|
||||
static void chat_onStatusChange(ToxWindow *self, Tox *m, int num, TOX_USERSTATUS status)
|
||||
@ -97,7 +97,7 @@ static void chat_onStatusMessageChange(ToxWindow *self, int num, uint8_t *status
|
||||
|
||||
StatusBar *statusbar = (StatusBar *) self->stb;
|
||||
statusbar->statusmsg_len = len;
|
||||
snprintf(statusbar->statusmsg, len, "%s", status);
|
||||
memcpy(statusbar->statusmsg, status, len);
|
||||
}
|
||||
|
||||
static void print_chat_help(ChatContext *ctx)
|
||||
|
@ -56,7 +56,7 @@ void friendlist_onNickChange(ToxWindow *self, int num, uint8_t *str, uint16_t le
|
||||
if (len >= TOX_MAX_NAME_LENGTH || num < 0 || num >= num_friends)
|
||||
return;
|
||||
|
||||
memcpy((char *) &friends[num].name, (char *) str, len);
|
||||
memcpy(friends[num].name, str, len);
|
||||
friends[num].namelength = len;
|
||||
}
|
||||
|
||||
@ -73,8 +73,8 @@ void friendlist_onStatusMessageChange(ToxWindow *self, int num, uint8_t *str, ui
|
||||
if (len >= TOX_MAX_STATUSMESSAGE_LENGTH || num < 0 || num >= num_friends)
|
||||
return;
|
||||
|
||||
memcpy(friends[num].statusmsg, str, len);
|
||||
friends[num].statusmsg_len = len;
|
||||
memcpy((char *) &friends[num].statusmsg, (char *) str, len);
|
||||
}
|
||||
|
||||
int friendlist_onFriendAdded(Tox *m, int num)
|
||||
@ -258,10 +258,9 @@ void disable_chatwin(int f_num)
|
||||
int get_friendnum(uint8_t *name)
|
||||
{
|
||||
int i;
|
||||
int len = strlen(name);
|
||||
|
||||
for (i = 0; i < num_friends; ++i) {
|
||||
if (strncmp(friends[i].name, name, len) == 0)
|
||||
if (strcmp(friends[i].name, name) == 0)
|
||||
return friends[i].num;
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)
|
||||
bool close_win = false;
|
||||
|
||||
if (line[0] == '/') {
|
||||
if (close_win = strncmp(line, "/close", strlen(line)) == 0) {
|
||||
if (close_win = strncmp(line, "/close", strlen("/close")) == 0) {
|
||||
set_active_window(0);
|
||||
int groupnum = self->num;
|
||||
delwin(ctx->linewin);
|
||||
|
34
src/prompt.c
34
src/prompt.c
@ -216,6 +216,39 @@ static void prompt_onInit(ToxWindow *self, Tox *m)
|
||||
wclrtoeol(self->window);
|
||||
}
|
||||
|
||||
static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int friendnum , uint8_t status)
|
||||
{
|
||||
if (friendnum < 0)
|
||||
return;
|
||||
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||
|
||||
if (tox_getname(m, friendnum, nick) == -1)
|
||||
return;
|
||||
|
||||
nick[TOXIC_MAX_NAME_LENGTH] = '\0';
|
||||
|
||||
if (!nick[0])
|
||||
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
||||
|
||||
if (status == 1) {
|
||||
wattron(self->window, COLOR_PAIR(GREEN));
|
||||
wattron(self->window, A_BOLD);
|
||||
wprintw(self->window, "\n%s ", nick);
|
||||
wattroff(self->window, A_BOLD);
|
||||
wprintw(self->window, "has come online\n");
|
||||
wattroff(self->window, COLOR_PAIR(GREEN));
|
||||
} else {
|
||||
wattron(self->window, COLOR_PAIR(RED));
|
||||
wattron(self->window, A_BOLD);
|
||||
wprintw(self->window, "\n%s ", nick);
|
||||
wattroff(self->window, A_BOLD);
|
||||
wprintw(self->window, "has gone offline\n");
|
||||
wattroff(self->window, COLOR_PAIR(RED));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void prompt_onFriendRequest(ToxWindow *self, uint8_t *key, uint8_t *data, uint16_t length)
|
||||
{
|
||||
wprintw(self->window, "\nFriend request from:\n");
|
||||
@ -301,6 +334,7 @@ ToxWindow new_prompt(void)
|
||||
ret.onKey = &prompt_onKey;
|
||||
ret.onDraw = &prompt_onDraw;
|
||||
ret.onInit = &prompt_onInit;
|
||||
ret.onConnectionChange = &prompt_onConnectionChange;
|
||||
ret.onFriendRequest = &prompt_onFriendRequest;
|
||||
ret.onGroupInvite = &prompt_onGroupInvite;
|
||||
|
||||
|
@ -29,28 +29,6 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userd
|
||||
|
||||
void on_connectionchange(Tox *m, int friendnumber, uint8_t status, void *userdata)
|
||||
{
|
||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||
tox_getname(m, friendnumber, nick);
|
||||
|
||||
if (!nick[0])
|
||||
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
||||
|
||||
if (status == 1) {
|
||||
wattron(prompt->window, COLOR_PAIR(GREEN));
|
||||
wattron(prompt->window, A_BOLD);
|
||||
wprintw(prompt->window, "\n%s ", nick);
|
||||
wattroff(prompt->window, A_BOLD);
|
||||
wprintw(prompt->window, "has come online\n");
|
||||
wattroff(prompt->window, COLOR_PAIR(GREEN));
|
||||
} else {
|
||||
wattron(prompt->window, COLOR_PAIR(RED));
|
||||
wattron(prompt->window, A_BOLD);
|
||||
wprintw(prompt->window, "\n%s ", nick);
|
||||
wattroff(prompt->window, A_BOLD);
|
||||
wprintw(prompt->window, "has gone offline\n");
|
||||
wattroff(prompt->window, COLOR_PAIR(RED));
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||
@ -96,7 +74,7 @@ void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, v
|
||||
char n_buf[strlen(string)+4]; /* must have room for chars relative to MAX_FRIENDS_NUM */
|
||||
snprintf(n_buf, sizeof(n_buf), "%s%d", string, friendnumber);
|
||||
strcpy(string, n_buf);
|
||||
length = strlen(string) + 1;
|
||||
length = strlen(n_buf) + 1;
|
||||
}
|
||||
|
||||
int i;
|
||||
|
Loading…
Reference in New Issue
Block a user