mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 15:53:26 +01:00
display status messages in friends list
This commit is contained in:
parent
c5b9677fc0
commit
73d6fba055
@ -322,17 +322,17 @@ void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd)
|
|||||||
|
|
||||||
if (!strncmp(status, "online", strlen("online"))) {
|
if (!strncmp(status, "online", strlen("online"))) {
|
||||||
status_kind = TOX_USERSTATUS_NONE;
|
status_kind = TOX_USERSTATUS_NONE;
|
||||||
status_text = "ONLINE";
|
status_text = "Online";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(status, "away", strlen("away"))) {
|
else if (!strncmp(status, "away", strlen("away"))) {
|
||||||
status_kind = TOX_USERSTATUS_AWAY;
|
status_kind = TOX_USERSTATUS_AWAY;
|
||||||
status_text = "AWAY";
|
status_text = "Away";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(status, "busy", strlen("busy"))) {
|
else if (!strncmp(status, "busy", strlen("busy"))) {
|
||||||
status_kind = TOX_USERSTATUS_BUSY;
|
status_kind = TOX_USERSTATUS_BUSY;
|
||||||
status_text = "BUSY";
|
status_text = "Busy";
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -21,7 +21,7 @@ extern int store_data(Tox *m, char *path);
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t name[TOX_MAX_NAME_LENGTH];
|
uint8_t name[TOX_MAX_NAME_LENGTH];
|
||||||
uint8_t status[TOX_MAX_STATUSMESSAGE_LENGTH];
|
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH];
|
||||||
int num;
|
int num;
|
||||||
int chatwin;
|
int chatwin;
|
||||||
bool active;
|
bool active;
|
||||||
@ -56,8 +56,8 @@ void friendlist_onStatusChange(ToxWindow *self, int num, uint8_t *str, uint16_t
|
|||||||
if (len >= TOX_MAX_STATUSMESSAGE_LENGTH || num >= num_friends)
|
if (len >= TOX_MAX_STATUSMESSAGE_LENGTH || num >= num_friends)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memcpy((char *) &friends[num].status, (char *) str, len);
|
memcpy((char *) &friends[num].statusmsg, (char *) str, len);
|
||||||
friends[num].status[len] = 0;
|
friends[num].statusmsg[len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int friendlist_onFriendAdded(Tox *m, int num)
|
int friendlist_onFriendAdded(Tox *m, int num)
|
||||||
@ -74,6 +74,7 @@ int friendlist_onFriendAdded(Tox *m, int num)
|
|||||||
friends[i].chatwin = -1;
|
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].name, "unknown");
|
||||||
|
strcpy((char *) friends[i].statusmsg, NOSTATUSMSG);
|
||||||
|
|
||||||
if (i == num_friends)
|
if (i == num_friends)
|
||||||
++num_friends;
|
++num_friends;
|
||||||
@ -173,7 +174,6 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
|||||||
for (i = 0; i < num_friends; ++i) {
|
for (i = 0; i < num_friends; ++i) {
|
||||||
if (friends[i].active) {
|
if (friends[i].active) {
|
||||||
bool is_online = tox_friendstatus(m, i) == TOX_FRIEND_ONLINE;
|
bool is_online = tox_friendstatus(m, i) == TOX_FRIEND_ONLINE;
|
||||||
TOX_USERSTATUS status = tox_get_userstatus(m, i);
|
|
||||||
|
|
||||||
if (i == num_selected)
|
if (i == num_selected)
|
||||||
wprintw(self->window, " > ");
|
wprintw(self->window, " > ");
|
||||||
@ -181,6 +181,7 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
|||||||
wprintw(self->window, " ");
|
wprintw(self->window, " ");
|
||||||
|
|
||||||
if (is_online) {
|
if (is_online) {
|
||||||
|
TOX_USERSTATUS status = tox_get_userstatus(m, i);
|
||||||
int colour;
|
int colour;
|
||||||
|
|
||||||
switch(status) {
|
switch(status) {
|
||||||
@ -200,14 +201,13 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wattron(self->window, COLOR_PAIR(colour));
|
wattron(self->window, COLOR_PAIR(colour));
|
||||||
attron(A_BOLD);
|
wprintw(self->window, "%s ", friends[i].name);
|
||||||
wprintw(self->window, "%s \n", friends[i].name);
|
|
||||||
attroff(A_BOLD);
|
|
||||||
wattroff(self->window, COLOR_PAIR(colour));
|
wattroff(self->window, COLOR_PAIR(colour));
|
||||||
|
|
||||||
|
if (strncmp(friends[i].statusmsg, NOSTATUSMSG, strlen(NOSTATUSMSG)))
|
||||||
|
wprintw(self->window, "(%s)\n", friends[i].statusmsg);
|
||||||
} else {
|
} else {
|
||||||
attron(A_BOLD);
|
wprintw(self->window, "%s (Offline)\n", friends[i].name);
|
||||||
wprintw(self->window, "%s \n", friends[i].name);
|
|
||||||
attroff(A_BOLD);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include "toxic_windows.h"
|
#include "toxic_windows.h"
|
||||||
#include "chat.h"
|
#include "chat.h"
|
||||||
|
|
||||||
|
#define NOSTATUSMSG "NOSTATUSMSG" /* Friends' default status message */
|
||||||
|
|
||||||
ToxWindow new_friendlist();
|
ToxWindow new_friendlist();
|
||||||
int friendlist_onFriendAdded(Tox *m, int num);
|
int friendlist_onFriendAdded(Tox *m, int num);
|
||||||
void disable_chatwin(int f_num);
|
void disable_chatwin(int f_num);
|
||||||
|
Loading…
Reference in New Issue
Block a user