diff options
-rw-r--r-- | toxcore/Messenger.c | 1 | ||||
-rw-r--r-- | toxcore/friend_requests.c | 19 | ||||
-rw-r--r-- | toxcore/friend_requests.h | 7 |
3 files changed, 27 insertions, 0 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index e1c2763c..6e103036 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -346,6 +346,7 @@ int m_delfriend(Messenger *m, int32_t friendnumber) | |||
346 | onion_delfriend(m->onion_c, m->friendlist[friendnumber].onion_friendnum); | 346 | onion_delfriend(m->onion_c, m->friendlist[friendnumber].onion_friendnum); |
347 | crypto_kill(m->net_crypto, m->friendlist[friendnumber].crypt_connection_id); | 347 | crypto_kill(m->net_crypto, m->friendlist[friendnumber].crypt_connection_id); |
348 | free(m->friendlist[friendnumber].statusmessage); | 348 | free(m->friendlist[friendnumber].statusmessage); |
349 | remove_request_received(&(m->fr), m->friendlist[friendnumber].client_id); | ||
349 | memset(&(m->friendlist[friendnumber]), 0, sizeof(Friend)); | 350 | memset(&(m->friendlist[friendnumber]), 0, sizeof(Friend)); |
350 | uint32_t i; | 351 | uint32_t i; |
351 | 352 | ||
diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c index 7574a881..469ab02d 100644 --- a/toxcore/friend_requests.c +++ b/toxcore/friend_requests.c | |||
@@ -113,6 +113,25 @@ static int request_received(Friend_Requests *fr, uint8_t *client_id) | |||
113 | return 0; | 113 | return 0; |
114 | } | 114 | } |
115 | 115 | ||
116 | /* Remove client id from received_requests list. | ||
117 | * | ||
118 | * return 0 if it removed it successfully. | ||
119 | * return -1 if it didn't find it. | ||
120 | */ | ||
121 | int remove_request_received(Friend_Requests *fr, uint8_t *client_id) | ||
122 | { | ||
123 | uint32_t i; | ||
124 | |||
125 | for (i = 0; i < MAX_RECEIVED_STORED; ++i) { | ||
126 | if (id_equal(fr->received_requests[i], client_id)) { | ||
127 | memset(fr->received_requests[i], 0, crypto_box_PUBLICKEYBYTES); | ||
128 | return 0; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | return -1; | ||
133 | } | ||
134 | |||
116 | 135 | ||
117 | static int friendreq_handlepacket(void *object, uint8_t *source_pubkey, uint8_t *packet, uint32_t length) | 136 | static int friendreq_handlepacket(void *object, uint8_t *source_pubkey, uint8_t *packet, uint32_t length) |
118 | { | 137 | { |
diff --git a/toxcore/friend_requests.h b/toxcore/friend_requests.h index 722c7431..eab359f0 100644 --- a/toxcore/friend_requests.h +++ b/toxcore/friend_requests.h | |||
@@ -55,6 +55,13 @@ int send_friendrequest(Onion_Client *onion_c, uint8_t *public_key, uint32_t nosp | |||
55 | void set_nospam(Friend_Requests *fr, uint32_t num); | 55 | void set_nospam(Friend_Requests *fr, uint32_t num); |
56 | uint32_t get_nospam(Friend_Requests *fr); | 56 | uint32_t get_nospam(Friend_Requests *fr); |
57 | 57 | ||
58 | /* Remove client id from received_requests list. | ||
59 | * | ||
60 | * return 0 if it removed it successfully. | ||
61 | * return -1 if it didn't find it. | ||
62 | */ | ||
63 | int remove_request_received(Friend_Requests *fr, uint8_t *client_id); | ||
64 | |||
58 | /* Set the function that will be executed when a friend request for us is received. | 65 | /* Set the function that will be executed when a friend request for us is received. |
59 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length, void * userdata) | 66 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length, void * userdata) |
60 | */ | 67 | */ |