From 8fac63f6df7e9231bf0642b50881f52162803914 Mon Sep 17 00:00:00 2001 From: Astonex Date: Sat, 3 Aug 2013 15:12:22 +0100 Subject: Changing status to offline when quitting wont overwrite last saved status --- testing/nTox_win32.c | 28 +++++++++++++++------------- testing/nTox_win32.h | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'testing') diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c index 55440828..5501ecf5 100644 --- a/testing/nTox_win32.c +++ b/testing/nTox_win32.c @@ -255,7 +255,7 @@ void change_nickname() fclose(name_file); } -void change_status() +void change_status(int savetofile) { uint8_t status[MAX_USERSTATUS_LENGTH]; int i = 0; @@ -274,10 +274,12 @@ void change_status() sprintf(numstring, "\n[i] changed status to %s\n\n", (char*)status); printf(numstring); - FILE* status_file = NULL; - status_file = fopen("statusfile.txt", "w"); - fprintf(status_file, "%s", (char*)status); - fclose(status_file); + if (savetofile == 1) { + FILE* status_file = NULL; + status_file = fopen("statusfile.txt", "w"); + fprintf(status_file, "%s", (char*)status); + fclose(status_file); + } } void accept_friend_request() @@ -298,7 +300,7 @@ void line_eval(char* line) char inpt_command = line[1]; if(inpt_command == 'f') { - add_friend(line); + add_friend(); } else if (inpt_command == 'r') { @@ -307,23 +309,23 @@ void line_eval(char* line) } else if (inpt_command == 'l') { - list_friends(line); + list_friends(); } else if (inpt_command == 'd') { - delete_friend(line); + delete_friend(); } /* Send message to friend */ else if (inpt_command == 'm') { - message_friend(line); + message_friend(); } else if (inpt_command == 'n') { - change_nickname(line); + change_nickname(); } else if (inpt_command == 's') { - change_status(line); + change_status(1); } else if (inpt_command == 'a') { @@ -332,8 +334,8 @@ void line_eval(char* line) } /* EXIT */ else if (inpt_command == 'q') { - strcpy(line, "Offline"); - change_status(line); + strcpy(line, "---Offline"); + change_status(0); exit(EXIT_SUCCESS); } } diff --git a/testing/nTox_win32.h b/testing/nTox_win32.h index 211ac95f..271403b8 100644 --- a/testing/nTox_win32.h +++ b/testing/nTox_win32.h @@ -39,7 +39,7 @@ void list_friends(); void delete_friend(); void message_friend(); void change_nickname(); -void change_status(); +void change_status(int savetofile); void accept_friend_request(); void line_eval(char* line); void get_input(); -- cgit v1.2.3