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

show pseudo-unique identifier in friend chat windows

This commit is contained in:
Jfreegman 2014-02-21 21:21:12 -05:00
parent 4294e39b49
commit 2982dc6ddd
4 changed files with 19 additions and 3 deletions

View File

@ -547,9 +547,9 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
self->x = x2;
/* Truncate note if it doesn't fit in statusbar */
uint16_t maxlen = x2 - getcurx(statusbar->topline) - 4;
uint16_t maxlen = x2 - getcurx(statusbar->topline) - (KEY_IDENT_DIGITS * 2) - 6;
if (statusbar->statusmsg_len > maxlen) {
statusbar->statusmsg[maxlen] = '\0';
statusbar->statusmsg[maxlen-1] = '\0';
statusbar->statusmsg_len = maxlen;
}
@ -559,7 +559,16 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
wattroff(statusbar->topline, A_BOLD);
}
wprintw(statusbar->topline, "\n");
wclrtoeol(statusbar->topline);
wmove(statusbar->topline, 0, x2 - (KEY_IDENT_DIGITS * 2) - 3);
wprintw(statusbar->topline, "{");
int i;
for (i = 0; i < KEY_IDENT_DIGITS; ++i)
wprintw(statusbar->topline, "%x", friends[self->num].pub_key[i] & 0xff);
wprintw(statusbar->topline, "}\n");
mvwhline(ctx->linewin, 0, 0, ACS_HLINE, x2);
}

View File

@ -130,6 +130,7 @@ static void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int num, bool sort
friends[i].online = false;
friends[i].status = TOX_USERSTATUS_NONE;
friends[i].namelength = tox_get_name(m, num, friends[i].name);
tox_get_client_id(m, num, friends[i].pub_key);
if (friends[i].namelength == -1 || friends[i].name[0] == '\0') {
strcpy(friends[i].name, (uint8_t *) UNKNOWN_NAME);

View File

@ -3,12 +3,15 @@
#include "toxic_windows.h"
#define KEY_IDENT_DIGITS 2
typedef struct {
uint8_t name[TOX_MAX_NAME_LENGTH];
uint16_t namelength;
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH];
uint16_t statusmsg_len;
uint8_t pending_groupchat[TOX_CLIENT_ID_SIZE];
uint8_t pub_key[TOX_CLIENT_ID_SIZE];
int num;
int chatwin;
bool active;

View File

@ -470,6 +470,9 @@ int main(int argc, char *argv[])
int i = 0;
int f_use_ipv4 = 0;
// Make sure all written files are read/writeable only by the current user.
umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
for (i = 0; i < argc; ++i) {
if (argv[i] == NULL)
break;