diff --git a/src/friendlist.c b/src/friendlist.c index 4192e35..03e1005 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -115,7 +115,7 @@ static void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int num) memset(friends[i].pending_groupchat, 0, TOX_CLIENT_ID_SIZE); if (friends[i].namelength == -1 || friends[i].name[0] == '\0') { - strcpy((char *) friends[i].name, UNKNOWN_NAME); + strcpy(friends[i].name, (uint8_t *) UNKNOWN_NAME); friends[i].namelength = strlen(UNKNOWN_NAME) + 1; } else { /* Enforce toxic's maximum name length */ friends[i].name[TOXIC_MAX_NAME_LENGTH] = '\0'; diff --git a/src/main.c b/src/main.c index 4747cd5..48925c9 100644 --- a/src/main.c +++ b/src/main.c @@ -371,12 +371,15 @@ static void do_file_senders(Tox *m) if (!file_senders[i].active) continue; - while (true) { - uint8_t *pathname = file_senders[i].pathname; - uint8_t filenum = file_senders[i].filenum; - uint64_t current_time = (uint64_t)time(NULL); - int friendnum = file_senders[i].friendnum; + uint8_t *pathname = file_senders[i].pathname; + uint8_t filenum = file_senders[i].filenum; + int friendnum = file_senders[i].friendnum; + uint64_t current_time = (uint64_t) time(NULL); + bool piece_sent = false; /* true if at least one file piece is successfuly sent */ + int pieces = 0; + + while (pieces++ < MAX_PIECES_SEND) { if (!tox_file_senddata(m, friendnum, filenum, file_senders[i].nextpiece, file_senders[i].piecelen)) { @@ -391,7 +394,7 @@ static void do_file_senders(Tox *m) break; } - file_senders[i].timestamp = current_time; + piece_sent = true; file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1, tox_filedata_size(m, friendnum), file_senders[i].file); @@ -402,6 +405,9 @@ static void do_file_senders(Tox *m) break; } } + + if (piece_sent) + file_senders[i].timestamp = current_time; } } diff --git a/src/prompt.c b/src/prompt.c index 422b1e2..ce261f6 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -157,7 +157,7 @@ static void prompt_onDraw(ToxWindow *self, Tox *m) wattroff(statusbar->topline, COLOR_PAIR(colour) | A_BOLD); } else { wattron(statusbar->topline, A_BOLD); - wprintw(statusbar->topline, "%s ", statusbar->nick); + wprintw(statusbar->topline, " %s ", statusbar->nick); wattroff(statusbar->topline, A_BOLD); wprintw(statusbar->topline, "[Offline]"); } diff --git a/src/toxic_windows.h b/src/toxic_windows.h index 1b80377..0bd7aaa 100644 --- a/src/toxic_windows.h +++ b/src/toxic_windows.h @@ -15,6 +15,8 @@ #include +#define UNKNOWN_NAME "Unknown" + #define MAX_WINDOWS_NUM 32 #define MAX_FRIENDS_NUM 100 #define MAX_GROUPCHAT_NUM MAX_WINDOWS_NUM - N_DEFAULT_WINS @@ -22,10 +24,10 @@ #define KEY_SIZE_BYTES 32 #define TOXIC_MAX_NAME_LENGTH 30 /* Must be <= TOX_MAX_NAME_LENGTH */ #define N_DEFAULT_WINS 2 /* number of permanent default windows */ -#define UNKNOWN_NAME "Unknown" +#define CURS_Y_OFFSET 3 /* y-axis cursor offset for chat contexts */ + #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 -#define CURS_Y_OFFSET 3 /* y-axis cursor offset for chat contexts */ /* Curses foreground colours (background is black) */ enum { @@ -102,7 +104,8 @@ typedef struct { #define MAX_FILES 256 #define FILE_PIECE_SIZE 1024 -#define TIMEOUT_FILESENDER 300 +#define TIMEOUT_FILESENDER 10 +#define MAX_PIECES_SEND 100 /* Max number of pieces to send per file per call to do_file_senders() */ typedef struct { FILE *file;