mirror of
				https://github.com/Tha14/toxic.git
				synced 2025-11-04 05:56:52 +01:00 
			
		
		
		
	Save messenger data on exit
This commit is contained in:
		@@ -19,6 +19,9 @@
 | 
			
		||||
 | 
			
		||||
#define CURS_Y_OFFSET 3
 | 
			
		||||
 | 
			
		||||
extern char *DATA_FILE;
 | 
			
		||||
extern int store_data(Tox *m, char *path);
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
    int friendnum;
 | 
			
		||||
    wchar_t line[MAX_STR_SIZE];
 | 
			
		||||
@@ -270,6 +273,7 @@ void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd)
 | 
			
		||||
 | 
			
		||||
    else if (!strcmp(cmd, "/quit") || !strcmp(cmd, "/exit") || !strcmp(cmd, "/q")) {
 | 
			
		||||
        endwin();
 | 
			
		||||
        store_data(m, DATA_FILE);
 | 
			
		||||
        tox_kill(m);
 | 
			
		||||
        exit(0);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -37,9 +37,8 @@ void friendlist_onMessage(ToxWindow *self, Tox *m, int num, uint8_t *str, uint16
 | 
			
		||||
    if (num >= num_friends)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    if (friends[num].chatwin == -1) {
 | 
			
		||||
    if (friends[num].chatwin == -1)
 | 
			
		||||
        friends[num].chatwin = add_window(m, new_chat(m, friends[num].num));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void friendlist_onNickChange(ToxWindow *self, int num, uint8_t *str, uint16_t len)
 | 
			
		||||
 
 | 
			
		||||
@@ -235,6 +235,7 @@ void cmd_connect(ToxWindow *self, Tox *m, int argc, char **argv)
 | 
			
		||||
void cmd_quit(ToxWindow *self, Tox *m, int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
    endwin();
 | 
			
		||||
    store_data(m, DATA_FILE);
 | 
			
		||||
    tox_kill(m);
 | 
			
		||||
    exit(0);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -64,11 +64,8 @@ void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, v
 | 
			
		||||
    int i;
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
 | 
			
		||||
        if (windows[i].onNickChange != NULL) {
 | 
			
		||||
        if (windows[i].onNickChange != NULL)
 | 
			
		||||
            windows[i].onNickChange(&windows[i], friendnumber, string, length);
 | 
			
		||||
            if (store_data(m, DATA_FILE))
 | 
			
		||||
                wprintw(prompt->window, "\nCould not store Tox data\n");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user