1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-24 03:23:25 +01:00

fix bug and load previous status messages on boot

This commit is contained in:
Jfreegman 2014-03-13 07:34:14 -04:00
parent 9d52b6ab5d
commit ac82961bea
2 changed files with 13 additions and 7 deletions

View File

@ -402,7 +402,6 @@ static void load_data(Tox *m, char *path)
void exit_toxic(Tox *m) void exit_toxic(Tox *m)
{ {
pthread_join(Winthread.tid, NULL);
store_data(m, DATA_FILE); store_data(m, DATA_FILE);
close_all_file_senders(); close_all_file_senders();
kill_all_windows(); kill_all_windows();
@ -500,7 +499,6 @@ int main(int argc, char *argv[])
} }
prompt = init_windows(m); prompt = init_windows(m);
prompt_init_statusbar(prompt, m);
/* create new thread for ncurses stuff */ /* create new thread for ncurses stuff */
if (pthread_mutex_init(&Winthread.lock, NULL) != 0) if (pthread_mutex_init(&Winthread.lock, NULL) != 0)
@ -550,6 +548,7 @@ int main(int argc, char *argv[])
} }
sort_friendlist_index(m); sort_friendlist_index(m);
prompt_init_statusbar(prompt, m);
while (true) { while (true) {
do_toxic(m, prompt); do_toxic(m, prompt);

View File

@ -36,6 +36,7 @@
uint8_t pending_frnd_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE] = {0}; uint8_t pending_frnd_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE] = {0};
uint8_t num_frnd_requests = 0; uint8_t num_frnd_requests = 0;
extern ToxWindow *prompt; extern ToxWindow *prompt;
struct _Winthread Winthread;
/* Array of global command names used for tab completion. */ /* Array of global command names used for tab completion. */
const uint8_t glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE] = { const uint8_t glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE] = {
@ -467,21 +468,27 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m)
statusbar->is_online = false; statusbar->is_online = false;
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'}; uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
uint8_t statusmsg[MAX_STR_SIZE];
pthread_mutex_lock(&Winthread.lock);
tox_get_self_name(m, nick, TOX_MAX_NAME_LENGTH); tox_get_self_name(m, nick, TOX_MAX_NAME_LENGTH);
tox_get_self_status_message(m, statusmsg, MAX_STR_SIZE);
pthread_mutex_unlock(&Winthread.lock);
snprintf(statusbar->nick, sizeof(statusbar->nick), "%s", nick); snprintf(statusbar->nick, sizeof(statusbar->nick), "%s", nick);
/* temporary until statusmessage saving works */ /* temporary until statusmessage saving works */
uint8_t ver[strlen(TOXICVER) + 1]; uint8_t ver[strlen(TOXICVER) + 1];
uint8_t statusmsg[MAX_STR_SIZE];
strcpy(ver, TOXICVER); strcpy(ver, TOXICVER);
uint8_t *toxic_ver = strtok(ver, "_"); uint8_t *toxic_ver = strtok(ver, "_");
if (toxic_ver != NULL) if (!strcmp("Online", statusmsg))
snprintf(statusmsg, MAX_STR_SIZE, "Toxing on Toxic v.%s", toxic_ver); snprintf(statusmsg, MAX_STR_SIZE, "Toxing on Toxic v.%s", toxic_ver);
else
snprintf(statusmsg, MAX_STR_SIZE, "Toxing on Toxic hacker edition");
m_set_statusmessage(m, statusmsg, strlen(statusmsg) + 1); pthread_mutex_lock(&Winthread.lock);
tox_set_status_message(m, statusmsg, strlen(statusmsg) + 1);
pthread_mutex_unlock(&Winthread.lock);
snprintf(statusbar->statusmsg, sizeof(statusbar->statusmsg), "%s", statusmsg); snprintf(statusbar->statusmsg, sizeof(statusbar->statusmsg), "%s", statusmsg);
/* Init statusbar subwindow */ /* Init statusbar subwindow */