diff options
Diffstat (limited to 'testing/nTox.c')
-rw-r--r-- | testing/nTox.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/testing/nTox.c b/testing/nTox.c index 693e64aa..199835a6 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -221,6 +221,25 @@ int main(int argc, char *argv[]) | |||
221 | int c; | 221 | int c; |
222 | int on = 0; | 222 | int on = 0; |
223 | initMessenger(); | 223 | initMessenger(); |
224 | FILE *data_file = NULL; | ||
225 | //if keyfiles exist | ||
226 | if ((data_file = fopen("data","r"))) { | ||
227 | //load keys | ||
228 | fseek(data_file, 0, SEEK_END); | ||
229 | int size = ftell(data_file); | ||
230 | fseek(data_file, 0, SEEK_SET); | ||
231 | uint8_t data[size]; | ||
232 | fread(data, sizeof(uint8_t), size, data_file); | ||
233 | Messenger_load(data, size); | ||
234 | } else { | ||
235 | //else save new keys | ||
236 | int size = Messenger_size(); | ||
237 | uint8_t data[size]; | ||
238 | Messenger_save(data); | ||
239 | data_file = fopen("data","w"); | ||
240 | fwrite(data, sizeof(uint8_t), size, data_file); | ||
241 | } | ||
242 | fclose(data_file); | ||
224 | m_callback_friendrequest(print_request); | 243 | m_callback_friendrequest(print_request); |
225 | m_callback_friendmessage(print_message); | 244 | m_callback_friendmessage(print_message); |
226 | m_callback_namechange(print_nickchange); | 245 | m_callback_namechange(print_nickchange); |