1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-26 23:03:27 +01:00

show name for default friend request message. also don't print key.

This commit is contained in:
Jfreegman 2013-11-17 23:14:27 -05:00
parent d69b82a7b4
commit 1ed6d83ed3
3 changed files with 13 additions and 16 deletions

View File

@ -177,7 +177,8 @@ static void delete_friend(Tox *m, ToxWindow *self, int f_num, wint_t key)
max_friends_index = i; max_friends_index = i;
--num_friends; --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; --num_selected;
sort_friendlist_index(); sort_friendlist_index();
@ -204,7 +205,6 @@ static void friendlist_onKey(ToxWindow *self, Tox *m, wint_t key)
} else { } else {
select_friend(m, key); select_friend(m, key);
} }
} }
static void friendlist_onDraw(ToxWindow *self, Tox *m) static void friendlist_onDraw(ToxWindow *self, Tox *m)

View File

@ -68,20 +68,23 @@ void cmd_add(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char
} }
char *id = argv[1]; char *id = argv[1];
uint8_t *msg; uint8_t msg[MAX_STR_SIZE];
if (argc > 1) { 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"); wprintw(window, "Message must be enclosed in quotes.\n");
return; return;
} }
msg[strlen(++msg)-1] = L'\0'; temp[strlen(++temp)-1] = L'\0';
snprintf(msg, sizeof(msg), "%s", temp);
} else } else {
msg = "Let's tox."; 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) { if (strlen(id) != 2 * TOX_FRIEND_ADDRESS_SIZE) {
wprintw(window, "Invalid ID length.\n"); wprintw(window, "Invalid ID length.\n");

View File

@ -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) static void prompt_onFriendRequest(ToxWindow *self, uint8_t *key, uint8_t *data, uint16_t length)
{ {
wprintw(self->window, "\nFriend request from:\n"); wprintw(self->window, "\nFriend request with the message: %s\n", data);
int i;
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); int n = add_friend_request(key);
if (n == -1) { if (n == -1) {