Skip to content

Commit

Permalink
Friends client id is now removed from the request received list when …
Browse files Browse the repository at this point in the history
…he is deleted.
  • Loading branch information
irungentoo committed Mar 21, 2014
1 parent d2d8965 commit 04001b2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions toxcore/Messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ int m_delfriend(Messenger *m, int32_t friendnumber)
onion_delfriend(m->onion_c, m->friendlist[friendnumber].onion_friendnum);
crypto_kill(m->net_crypto, m->friendlist[friendnumber].crypt_connection_id);
free(m->friendlist[friendnumber].statusmessage);
remove_request_received(&(m->fr), m->friendlist[friendnumber].client_id);
memset(&(m->friendlist[friendnumber]), 0, sizeof(Friend));
uint32_t i;

Expand Down
19 changes: 19 additions & 0 deletions toxcore/friend_requests.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ static int request_received(Friend_Requests *fr, uint8_t *client_id)
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)
{
Expand Down
7 changes: 7 additions & 0 deletions toxcore/friend_requests.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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.
* Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length, void * userdata)
*/
Expand Down

0 comments on commit 04001b2

Please sign in to comment.