Friends client id is now removed from the request received list when he is deleted.

This commit is contained in:
irungentoo 2014-03-21 19:27:17 -04:00
parent d2d8965470
commit 04001b2ec3
3 changed files with 27 additions and 0 deletions

View File

@ -346,6 +346,7 @@ int m_delfriend(Messenger *m, int32_t friendnumber)
onion_delfriend(m->onion_c, m->friendlist[friendnumber].onion_friendnum); onion_delfriend(m->onion_c, m->friendlist[friendnumber].onion_friendnum);
crypto_kill(m->net_crypto, m->friendlist[friendnumber].crypt_connection_id); crypto_kill(m->net_crypto, m->friendlist[friendnumber].crypt_connection_id);
free(m->friendlist[friendnumber].statusmessage); free(m->friendlist[friendnumber].statusmessage);
remove_request_received(&(m->fr), m->friendlist[friendnumber].client_id);
memset(&(m->friendlist[friendnumber]), 0, sizeof(Friend)); memset(&(m->friendlist[friendnumber]), 0, sizeof(Friend));
uint32_t i; uint32_t i;

View File

@ -113,6 +113,25 @@ static int request_received(Friend_Requests *fr, uint8_t *client_id)
return 0; return 0;
} }
/* Remove client id from received_requests list.
*
* return 0 if it removed it successfully.
* return -1 if it didn't find it.
*/
int remove_request_received(Friend_Requests *fr, uint8_t *client_id)
{
uint32_t i;
for (i = 0; i < MAX_RECEIVED_STORED; ++i) {
if (id_equal(fr->received_requests[i], client_id)) {
memset(fr->received_requests[i], 0, crypto_box_PUBLICKEYBYTES);
return 0;
}
}
return -1;
}
static int friendreq_handlepacket(void *object, uint8_t *source_pubkey, uint8_t *packet, uint32_t length) static int friendreq_handlepacket(void *object, uint8_t *source_pubkey, uint8_t *packet, uint32_t length)
{ {

View File

@ -55,6 +55,13 @@ int send_friendrequest(Onion_Client *onion_c, uint8_t *public_key, uint32_t nosp
void set_nospam(Friend_Requests *fr, uint32_t num); void set_nospam(Friend_Requests *fr, uint32_t num);
uint32_t get_nospam(Friend_Requests *fr); uint32_t get_nospam(Friend_Requests *fr);
/* Remove client id from received_requests list.
*
* return 0 if it removed it successfully.
* return -1 if it didn't find it.
*/
int remove_request_received(Friend_Requests *fr, uint8_t *client_id);
/* Set the function that will be executed when a friend request for us is received. /* Set the function that will be executed when a friend request for us is received.
* Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length, void * userdata) * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length, void * userdata)
*/ */