1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-26 14:13:27 +01:00

Merge branch 'master' into new_groupchats

This commit is contained in:
Jfreegman 2015-12-06 22:12:02 -05:00
commit 7e122ceec6
2 changed files with 19 additions and 22 deletions

View File

@ -822,11 +822,6 @@ on_error:
void stop_current_call(ToxWindow* self)
{
Call *this_call = &CallControl.calls[self->num];
if ( !this_call )
return;
if ( CallControl.pending_call ) {
toxav_call_control(CallControl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, NULL);
callback_call_canceled(self->num);

View File

@ -40,6 +40,7 @@ extern FriendsList Friends;
/* Checks for timed out file transfers and closes them. */
#define CHECK_FILE_TIMEOUT_INTERAVAL 5
void check_file_transfer_timeouts(Tox *m)
{
char msg[MAX_STR_SIZE];
@ -79,46 +80,47 @@ void check_file_transfer_timeouts(Tox *m)
}
/* creates initial progress line that will be updated during file transfer.
Assumes progline is of size MAX_STR_SIZE */
Assumes progline has room for at least MAX_STR_SIZE bytes */
void init_progress_bar(char *progline)
{
strcpy(progline, "0.0 B/s [");
strcpy(progline, "0% [");
int i;
for (i = 0; i < NUM_PROG_MARKS; ++i)
strcat(progline, "-");
strcat(progline, "] 0%");
strcat(progline, "] 0.0 B/s");
}
/* prints a progress bar for file transfers.
if friendnum is -1 we're sending the file, otherwise we're receiving. */
/* prints a progress bar for file transfers. */
void print_progress_bar(ToxWindow *self, double bps, double pct_done, uint32_t line_id)
{
if (bps < 0 || pct_done < 0 || pct_done > 100)
return;
char msg[MAX_STR_SIZE];
bytes_convert_str(msg, sizeof(msg), bps);
strcat(msg, "/s [");
char pct_str[24];
snprintf(pct_str, sizeof(pct_str), "%.1f%%", pct_done);
char bps_str[24];
bytes_convert_str(bps_str, sizeof(bps_str), bps);
char prog_line[NUM_PROG_MARKS + 1] = {0};
int n = pct_done / (100 / NUM_PROG_MARKS);
int i, j;
for (i = 0; i < n; ++i)
strcat(msg, "#");
strcat(prog_line, "=");
for (j = i; j < NUM_PROG_MARKS; ++j)
strcat(msg, "-");
if (pct_done < 100)
strcpy(prog_line + n, ">");
strcat(msg, "] ");
for (j = i; j < NUM_PROG_MARKS - 1; ++j)
strcat(prog_line, "-");
char pctstr[16];
const char *frmt = pct_done == 100 ? "%.f%%" : "%.1f%%";
snprintf(pctstr, sizeof(pctstr), frmt, pct_done);
strcat(msg, pctstr);
char full_line[strlen(pct_str) + NUM_PROG_MARKS + strlen(bps_str) + 7];
snprintf(full_line, sizeof(full_line), "%s [%s] %s/s", pct_str, prog_line, bps_str);
line_info_set(self, line_id, msg);
line_info_set(self, line_id, full_line);
}
static void refresh_progress_helper(ToxWindow *self, Tox *m, struct FileTransfer *ft)