mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-13 02:23:01 +01:00
properly implemented statuses
This commit is contained in:
parent
d636cc9780
commit
c5b9677fc0
@ -24,7 +24,7 @@ typedef struct {
|
||||
uint8_t status[TOX_MAX_STATUSMESSAGE_LENGTH];
|
||||
int num;
|
||||
int chatwin;
|
||||
bool active;
|
||||
bool active;
|
||||
} friend_t;
|
||||
|
||||
static friend_t friends[MAX_FRIENDS_NUM];
|
||||
@ -72,9 +72,8 @@ 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);
|
||||
//tox_getname(m, num, friends[i].name);
|
||||
strcpy((char *) friends[i].name, "unknown");
|
||||
strcpy((char *) friends[i].status, "Offline");
|
||||
|
||||
if (i == num_friends)
|
||||
++num_friends;
|
||||
@ -173,19 +172,43 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
||||
|
||||
for (i = 0; i < num_friends; ++i) {
|
||||
if (friends[i].active) {
|
||||
if (i == num_selected)
|
||||
wattron(self->window, COLOR_PAIR(3));
|
||||
|
||||
wprintw(self->window, " > ");
|
||||
bool is_online = tox_friendstatus(m, i) == TOX_FRIEND_ONLINE;
|
||||
TOX_USERSTATUS status = tox_get_userstatus(m, i);
|
||||
|
||||
if (i == num_selected)
|
||||
wattroff(self->window, COLOR_PAIR(3));
|
||||
wprintw(self->window, " > ");
|
||||
else
|
||||
wprintw(self->window, " ");
|
||||
|
||||
attron(A_BOLD);
|
||||
wprintw(self->window, "%s ", friends[i].name);
|
||||
attroff(A_BOLD);
|
||||
if (is_online) {
|
||||
int colour;
|
||||
|
||||
wprintw(self->window, "(%s)\n", friends[i].status);
|
||||
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;
|
||||
}
|
||||
|
||||
wattron(self->window, COLOR_PAIR(colour));
|
||||
attron(A_BOLD);
|
||||
wprintw(self->window, "%s \n", friends[i].name);
|
||||
attroff(A_BOLD);
|
||||
wattroff(self->window, COLOR_PAIR(colour));
|
||||
} else {
|
||||
attron(A_BOLD);
|
||||
wprintw(self->window, "%s \n", friends[i].name);
|
||||
attroff(A_BOLD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,13 +294,13 @@ void cmd_status(ToxWindow *self, Tox *m, char **args)
|
||||
|
||||
if (!strncmp(status, "online", strlen("online"))) {
|
||||
status_kind = TOX_USERSTATUS_NONE;
|
||||
status_text = "ONLINE";
|
||||
status_text = "Online";
|
||||
} else if (!strncmp(status, "away", strlen("away"))) {
|
||||
status_kind = TOX_USERSTATUS_AWAY;
|
||||
status_text = "AWAY";
|
||||
status_text = "Away";
|
||||
} else if (!strncmp(status, "busy", strlen("busy"))) {
|
||||
status_kind = TOX_USERSTATUS_BUSY;
|
||||
status_text = "BUSY";
|
||||
status_text = "Busy";
|
||||
} else {
|
||||
wprintw(self->window, "Invalid status.\n");
|
||||
return;
|
||||
|
@ -84,9 +84,8 @@ void on_friendadded(Tox *m, int friendnumber)
|
||||
{
|
||||
friendlist_onFriendAdded(m, friendnumber);
|
||||
|
||||
if (store_data(m, DATA_FILE)) {
|
||||
if (store_data(m, DATA_FILE))
|
||||
wprintw(prompt->window, "\nCould not store Tox data\n");
|
||||
}
|
||||
}
|
||||
/* CALLBACKS END */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user