mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-12 23:43:02 +01:00
show name for default friend request message. also don't print key.
This commit is contained in:
parent
d69b82a7b4
commit
1ed6d83ed3
@ -177,7 +177,8 @@ static void delete_friend(Tox *m, ToxWindow *self, int f_num, wint_t key)
|
||||
max_friends_index = i;
|
||||
--num_friends;
|
||||
|
||||
if (num_selected == num_friends)
|
||||
/* make sure num_selected stays within num_friends range */
|
||||
if (num_friends && num_selected == num_friends)
|
||||
--num_selected;
|
||||
|
||||
sort_friendlist_index();
|
||||
@ -204,7 +205,6 @@ static void friendlist_onKey(ToxWindow *self, Tox *m, wint_t key)
|
||||
} else {
|
||||
select_friend(m, key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
||||
|
@ -68,20 +68,23 @@ void cmd_add(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char
|
||||
}
|
||||
|
||||
char *id = argv[1];
|
||||
uint8_t *msg;
|
||||
uint8_t msg[MAX_STR_SIZE];
|
||||
|
||||
if (argc > 1) {
|
||||
msg = argv[2];
|
||||
uint8_t *temp = argv[2];
|
||||
|
||||
if (msg[0] != '\"') {
|
||||
if (temp[0] != '\"') {
|
||||
wprintw(window, "Message must be enclosed in quotes.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
msg[strlen(++msg)-1] = L'\0';
|
||||
|
||||
} else
|
||||
msg = "Let's tox.";
|
||||
temp[strlen(++temp)-1] = L'\0';
|
||||
snprintf(msg, sizeof(msg), "%s", temp);
|
||||
} else {
|
||||
uint8_t selfname[TOX_MAX_NAME_LENGTH];
|
||||
tox_getselfname(m, selfname, TOX_MAX_NAME_LENGTH);
|
||||
snprintf(msg, sizeof(msg), "Hello, my name is %s. Care to Tox?", selfname);
|
||||
}
|
||||
|
||||
if (strlen(id) != 2 * TOX_FRIEND_ADDRESS_SIZE) {
|
||||
wprintw(window, "Invalid ID length.\n");
|
||||
|
@ -217,14 +217,8 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int friendnum , u
|
||||
|
||||
static void prompt_onFriendRequest(ToxWindow *self, uint8_t *key, uint8_t *data, uint16_t length)
|
||||
{
|
||||
wprintw(self->window, "\nFriend request from:\n");
|
||||
int i;
|
||||
wprintw(self->window, "\nFriend request with the message: %s\n", data);
|
||||
|
||||
for (i = 0; i < KEY_SIZE_BYTES; ++i) {
|
||||
wprintw(self->window, "%02x", key[i] & 0xff);
|
||||
}
|
||||
|
||||
wprintw(self->window, "\n\nWith the message: %s\n\n", data);
|
||||
int n = add_friend_request(key);
|
||||
|
||||
if (n == -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user