1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-07-01 16:57:45 +02:00

Show offline friends names and some cosmetic changes

This commit is contained in:
Jfreegman 2013-09-03 21:31:50 -04:00
parent 577f42c075
commit aa6e205ee8
2 changed files with 13 additions and 13 deletions

View File

@ -102,7 +102,7 @@ static void chat_onNickChange(ToxWindow *self, int num, uint8_t *nick, uint16_t
wattroff(ctx->history, COLOR_PAIR(2));
nick[len - 1] = '\0';
snprintf(self->title, sizeof(self->title), "[%s (%d)]", nick, num);
snprintf(self->title, sizeof(self->title), "[%s]", nick);
wprintw(ctx->history, "* Chat partner changed nick to '%s'\n", nick);
}
@ -444,7 +444,7 @@ ToxWindow new_chat(Tox *m, int friendnum)
uint8_t nick[TOX_MAX_NAME_LENGTH] = {0};
tox_getname(m, friendnum, (uint8_t *) &nick);
snprintf(ret.title, sizeof(ret.title), "[%s (%d)]", nick, friendnum);
snprintf(ret.title, sizeof(ret.title), "[%s]", nick);
ChatContext *x = calloc(1, sizeof(ChatContext));
ret.x = x;

View File

@ -72,8 +72,10 @@ int friendlist_onFriendAdded(Tox *m, int num)
friends[i].num = num;
friends[i].active = true;
friends[i].chatwin = -1;
//tox_getname(m, num, friends[i].name);
strcpy((char *) friends[i].name, "unknown");
if (tox_getname(m, num, friends[i].name) != 0 || friends[i].name[0] == '\0')
strcpy((char *) friends[i].name, "unknown");
strcpy((char *) friends[i].statusmsg, NOSTATUSMSG);
if (i == num_friends)
@ -164,8 +166,8 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
wprintw(self->window, "Empty. Add some friends! :-)\n");
} else {
wattron(self->window, COLOR_PAIR(2) | A_BOLD);
wprintw(self->window, " * Open chat with up/down keys and enter.\n");
wprintw(self->window, " * Delete friends with the backspace key.\n\n");
wprintw(self->window, " Open chat with up/down keys and enter.\n");
wprintw(self->window, " Delete friends with the backspace key.\n\n");
wattroff(self->window, COLOR_PAIR(2) | A_BOLD);
}
@ -182,33 +184,31 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
if (is_online) {
TOX_USERSTATUS status = tox_get_userstatus(m, friends[i].num);
int colour;
int colour = 7; /* Invalid or other errors default to black */
switch(status) {
case TOX_USERSTATUS_NONE:
colour = 1;
break;
case TOX_USERSTATUS_AWAY:
colour = 5;
break;
case TOX_USERSTATUS_BUSY:
case TOX_USERSTATUS_INVALID:
default:
colour = 3;
break;
}
wprintw(self->window, "[");
wattron(self->window, COLOR_PAIR(colour));
wprintw(self->window, "%s ", friends[i].name);
wprintw(self->window, "O");
wattroff(self->window, COLOR_PAIR(colour));
wprintw(self->window, "] %s ", friends[i].name);
if (strncmp(friends[i].statusmsg, NOSTATUSMSG, strlen(NOSTATUSMSG)))
wprintw(self->window, "(%s)\n", friends[i].statusmsg);
} else {
wprintw(self->window, "%s (Offline)\n", friends[i].name);
wprintw(self->window, "[O] %s (Offline)\n", friends[i].name);
}
}
}