diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-17 10:52:04 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-08-18 00:01:53 +0100 |
commit | a5e35180c7b42d30c82825cd67c8118ce048f65a (patch) | |
tree | b74e8ece4f78a988ab0a1300cc08bd35fcd63662 /toxcore/Messenger.c | |
parent | db22522741cccdeba657776844538c71cf8e8e7a (diff) |
Make tox_callback_friend_name stateless.
See #27 and #40 for details.
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index c6c503ca..e5779fb6 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -162,7 +162,7 @@ static int send_offline_packet(Messenger *m, int friendcon_id) | |||
162 | } | 162 | } |
163 | 163 | ||
164 | static int handle_status(void *object, int i, uint8_t status); | 164 | static int handle_status(void *object, int i, uint8_t status); |
165 | static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len); | 165 | static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len, void *userdata); |
166 | static int handle_custom_lossy_packet(void *object, int friend_num, const uint8_t *packet, uint16_t length); | 166 | static int handle_custom_lossy_packet(void *object, int friend_num, const uint8_t *packet, uint16_t length); |
167 | 167 | ||
168 | static int32_t init_new_friend(Messenger *m, const uint8_t *real_pk, uint8_t status) | 168 | static int32_t init_new_friend(Messenger *m, const uint8_t *real_pk, uint8_t status) |
@@ -777,11 +777,9 @@ void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, uint3 | |||
777 | m->friend_message_userdata = userdata; | 777 | m->friend_message_userdata = userdata; |
778 | } | 778 | } |
779 | 779 | ||
780 | void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, size_t, void *), | 780 | void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, size_t, void *)) |
781 | void *userdata) | ||
782 | { | 781 | { |
783 | m->friend_namechange = function; | 782 | m->friend_namechange = function; |
784 | m->friend_namechange_userdata = userdata; | ||
785 | } | 783 | } |
786 | 784 | ||
787 | void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, size_t, void *), | 785 | void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, size_t, void *), |
@@ -1904,7 +1902,7 @@ static int handle_status(void *object, int i, uint8_t status) | |||
1904 | return 0; | 1902 | return 0; |
1905 | } | 1903 | } |
1906 | 1904 | ||
1907 | static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len) | 1905 | static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len, void *userdata) |
1908 | { | 1906 | { |
1909 | if (len == 0) | 1907 | if (len == 0) |
1910 | return -1; | 1908 | return -1; |
@@ -1943,7 +1941,7 @@ static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len) | |||
1943 | 1941 | ||
1944 | /* inform of namechange before we overwrite the old name */ | 1942 | /* inform of namechange before we overwrite the old name */ |
1945 | if (m->friend_namechange) | 1943 | if (m->friend_namechange) |
1946 | m->friend_namechange(m, i, data_terminated, data_length, m->friend_namechange_userdata); | 1944 | m->friend_namechange(m, i, data_terminated, data_length, userdata); |
1947 | 1945 | ||
1948 | memcpy(m->friendlist[i].name, data_terminated, data_length); | 1946 | memcpy(m->friendlist[i].name, data_terminated, data_length); |
1949 | m->friendlist[i].name_length = data_length; | 1947 | m->friendlist[i].name_length = data_length; |
@@ -2306,7 +2304,7 @@ void do_messenger(Messenger *m, void *userdata) | |||
2306 | unix_time_update(); | 2304 | unix_time_update(); |
2307 | 2305 | ||
2308 | if (!m->options.udp_disabled) { | 2306 | if (!m->options.udp_disabled) { |
2309 | networking_poll(m->net); | 2307 | networking_poll(m->net, userdata); |
2310 | do_DHT(m->dht); | 2308 | do_DHT(m->dht); |
2311 | } | 2309 | } |
2312 | 2310 | ||
@@ -2314,7 +2312,7 @@ void do_messenger(Messenger *m, void *userdata) | |||
2314 | do_TCP_server(m->tcp_server); | 2312 | do_TCP_server(m->tcp_server); |
2315 | } | 2313 | } |
2316 | 2314 | ||
2317 | do_net_crypto(m->net_crypto); | 2315 | do_net_crypto(m->net_crypto, userdata); |
2318 | do_onion_client(m->onion_c); | 2316 | do_onion_client(m->onion_c); |
2319 | do_friend_connections(m->fr_c); | 2317 | do_friend_connections(m->fr_c); |
2320 | do_friends(m); | 2318 | do_friends(m); |