diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-16 19:45:20 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-16 19:45:20 -0400 |
commit | ffa809b3797e1e8fba4c1c495c4990cae44477d7 (patch) | |
tree | 4aec372764715c161331ec6aa32f933057bc045b | |
parent | bec416a05058ed821e9c16e3dda477abed41ec0d (diff) |
ncurses test now tells you when you connect to the DHT.
-rw-r--r-- | core/DHT.c | 16 | ||||
-rw-r--r-- | core/DHT.h | 3 | ||||
-rw-r--r-- | testing/nTox.c | 9 |
3 files changed, 28 insertions, 0 deletions
@@ -1017,3 +1017,19 @@ int DHT_load(uint8_t * data, uint32_t size) | |||
1017 | } | 1017 | } |
1018 | return 0; | 1018 | return 0; |
1019 | } | 1019 | } |
1020 | |||
1021 | //returns 0 if we are not connected to the DHT | ||
1022 | //returns 1 if we are | ||
1023 | int DHT_isconnected() | ||
1024 | { | ||
1025 | uint32_t i; | ||
1026 | uint32_t temp_time = unix_time(); | ||
1027 | for(i = 0; i < LCLIENT_LIST; i++) | ||
1028 | { | ||
1029 | if(close_clientlist[i].timestamp + BAD_NODE_TIMEOUT > temp_time) | ||
1030 | { | ||
1031 | return 1; | ||
1032 | } | ||
1033 | } | ||
1034 | return 0; | ||
1035 | } \ No newline at end of file | ||
@@ -86,5 +86,8 @@ void DHT_save(uint8_t * data); | |||
86 | //return 0 if success | 86 | //return 0 if success |
87 | int DHT_load(uint8_t * data, uint32_t size); | 87 | int DHT_load(uint8_t * data, uint32_t size); |
88 | 88 | ||
89 | //returns 0 if we are not connected to the DHT | ||
90 | //returns 1 if we are | ||
91 | int DHT_isconnected(); | ||
89 | 92 | ||
90 | #endif | 93 | #endif |
diff --git a/testing/nTox.c b/testing/nTox.c index acc0be89..d3f6e6a8 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -169,6 +169,7 @@ int main(int argc, char *argv[]) | |||
169 | exit(0); | 169 | exit(0); |
170 | } | 170 | } |
171 | int c; | 171 | int c; |
172 | int on = 0; | ||
172 | initMessenger(); | 173 | initMessenger(); |
173 | m_callback_friendrequest(print_request); | 174 | m_callback_friendrequest(print_request); |
174 | m_callback_friendmessage(print_message); | 175 | m_callback_friendmessage(print_message); |
@@ -219,6 +220,14 @@ int main(int argc, char *argv[]) | |||
219 | break; | 220 | break; |
220 | } | 221 | } |
221 | } | 222 | } |
223 | if(on == 0) | ||
224 | { | ||
225 | if(DHT_isconnected()) | ||
226 | { | ||
227 | new_lines("You are now connected to the DHT."); | ||
228 | on = 1; | ||
229 | } | ||
230 | } | ||
222 | doMessenger(); | 231 | doMessenger(); |
223 | c_sleep(1); | 232 | c_sleep(1); |
224 | do_refresh(); | 233 | do_refresh(); |