mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
fix for #288
nTox will now display a message if you try to accept a not yet received or already accepted friend request
This commit is contained in:
parent
68317c8d51
commit
5817c2c888
|
@ -42,7 +42,12 @@ char *help = "[i] commands:\n/f ID (to add friend)\n/m friendnumber message "
|
||||||
"name)\n/q (to quit)";
|
"name)\n/q (to quit)";
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
uint8_t pending_requests[256][CLIENT_ID_SIZE];
|
typedef struct {
|
||||||
|
uint8_t id[CLIENT_ID_SIZE];
|
||||||
|
uint8_t accepted;
|
||||||
|
} Friend_request;
|
||||||
|
|
||||||
|
Friend_request pending_requests[256];
|
||||||
uint8_t num_requests = 0;
|
uint8_t num_requests = 0;
|
||||||
|
|
||||||
void get_id(char *data)
|
void get_id(char *data)
|
||||||
|
@ -229,15 +234,21 @@ void line_eval(char *line)
|
||||||
else if (inpt_command == 'a') {
|
else if (inpt_command == 'a') {
|
||||||
uint8_t numf = atoi(line + 3);
|
uint8_t numf = atoi(line + 3);
|
||||||
char numchar[100];
|
char numchar[100];
|
||||||
int num = m_addfriend_norequest(pending_requests[numf]);
|
if(numf >= num_requests || pending_requests[numf].accepted) {
|
||||||
if (num != -1) {
|
sprintf(numchar,"[i] you either didn't receive that request or you already accepted it");
|
||||||
sprintf(numchar, "[i] friend request %u accepted", numf);
|
|
||||||
new_lines(numchar);
|
|
||||||
sprintf(numchar, "[i] added friendnumber %d", num);
|
|
||||||
new_lines(numchar);
|
new_lines(numchar);
|
||||||
} else {
|
} else {
|
||||||
sprintf(numchar, "[i] failed to add friend");
|
int num = m_addfriend_norequest(pending_requests[numf].id);
|
||||||
new_lines(numchar);
|
if (num != -1) {
|
||||||
|
pending_requests[numf].accepted = 1;
|
||||||
|
sprintf(numchar, "[i] friend request %u accepted", numf);
|
||||||
|
new_lines(numchar);
|
||||||
|
sprintf(numchar, "[i] added friendnumber %d", num);
|
||||||
|
new_lines(numchar);
|
||||||
|
} else {
|
||||||
|
sprintf(numchar, "[i] failed to add friend");
|
||||||
|
new_lines(numchar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
do_refresh();
|
do_refresh();
|
||||||
}
|
}
|
||||||
|
@ -330,7 +341,8 @@ void print_request(uint8_t *public_key, uint8_t *data, uint16_t length)
|
||||||
char numchar[100];
|
char numchar[100];
|
||||||
sprintf(numchar, "[i] accept request with /a %u", num_requests);
|
sprintf(numchar, "[i] accept request with /a %u", num_requests);
|
||||||
new_lines(numchar);
|
new_lines(numchar);
|
||||||
memcpy(pending_requests[num_requests], public_key, CLIENT_ID_SIZE);
|
memcpy(pending_requests[num_requests].id, public_key, CLIENT_ID_SIZE);
|
||||||
|
pending_requests[num_requests].accepted = 0;
|
||||||
++num_requests;
|
++num_requests;
|
||||||
do_refresh();
|
do_refresh();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user