From ffa809b3797e1e8fba4c1c495c4990cae44477d7 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 16 Jul 2013 19:45:20 -0400 Subject: ncurses test now tells you when you connect to the DHT. --- core/DHT.c | 16 ++++++++++++++++ core/DHT.h | 3 +++ testing/nTox.c | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/core/DHT.c b/core/DHT.c index 18f2de38..399d491b 100644 --- a/core/DHT.c +++ b/core/DHT.c @@ -1017,3 +1017,19 @@ int DHT_load(uint8_t * data, uint32_t size) } return 0; } + +//returns 0 if we are not connected to the DHT +//returns 1 if we are +int DHT_isconnected() +{ + uint32_t i; + uint32_t temp_time = unix_time(); + for(i = 0; i < LCLIENT_LIST; i++) + { + if(close_clientlist[i].timestamp + BAD_NODE_TIMEOUT > temp_time) + { + return 1; + } + } + return 0; +} \ No newline at end of file diff --git a/core/DHT.h b/core/DHT.h index d5c2c57d..edc4d344 100644 --- a/core/DHT.h +++ b/core/DHT.h @@ -86,5 +86,8 @@ void DHT_save(uint8_t * data); //return 0 if success int DHT_load(uint8_t * data, uint32_t size); +//returns 0 if we are not connected to the DHT +//returns 1 if we are +int DHT_isconnected(); #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[]) exit(0); } int c; + int on = 0; initMessenger(); m_callback_friendrequest(print_request); m_callback_friendmessage(print_message); @@ -219,6 +220,14 @@ int main(int argc, char *argv[]) break; } } + if(on == 0) + { + if(DHT_isconnected()) + { + new_lines("You are now connected to the DHT."); + on = 1; + } + } doMessenger(); c_sleep(1); do_refresh(); -- cgit v1.2.3