1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-22 20:43:02 +01:00

format fixes

This commit is contained in:
Jfreegman 2013-10-11 04:42:30 -04:00
parent 698c18521a
commit 75d356e52a
7 changed files with 35 additions and 28 deletions

View File

@ -99,15 +99,16 @@ static void chat_onStatusMessageChange(ToxWindow *self, int num, uint8_t *status
memcpy(statusbar->statusmsg, status, len);
}
static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int num, uint8_t filenum, uint64_t filesize,
uint8_t *filename, uint16_t filename_len)
static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int num, uint8_t filenum,
uint64_t filesize, uint8_t *filename, uint16_t filename_len)
{
if (self-> num != num)
return;
ChatContext *ctx = (ChatContext *) self->chatwin;
wprintw(ctx->history, "File transfer request for '%s' of size %llu.\n", filename, (long long unsigned int)filesize);
wprintw(ctx->history, "File transfer request for '%s' of size %llu.\n", filename,
(long long unsigned int)filesize);
if (filenum > MAX_FILENUMBER) {
wprintw(ctx->history, "Too many pending file requests; discarding.\n");
@ -123,8 +124,8 @@ static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int num, uint8_t fil
}
static void chat_onFileControl(ToxWindow *self, Tox *m, int num, uint8_t receive_send, uint8_t filenum,
uint8_t control_type, uint8_t *data, uint16_t length)
static void chat_onFileControl(ToxWindow *self, Tox *m, int num, uint8_t receive_send,
uint8_t filenum, uint8_t control_type, uint8_t *data, uint16_t length)
{
if (self->num != num)
return;
@ -147,7 +148,8 @@ static void chat_onFileControl(ToxWindow *self, Tox *m, int num, uint8_t receive
beep();
}
static void chat_onFileData(ToxWindow *self, Tox *m, int num, uint8_t filenum, uint8_t *data, uint16_t length)
static void chat_onFileData(ToxWindow *self, Tox *m, int num, uint8_t filenum, uint8_t *data,
uint16_t length)
{
if (self->num != num)
return;

View File

@ -197,7 +197,8 @@ void cmd_file(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
int friendnum = pending_file_transfers[filenum];
if (tox_file_sendcontrol(m, friendnum, 1, filenum, 0, 0, 0))
wprintw(window, "Accepted file transfer %u. Saving file as %d.%u.bin.\n", filenum, friendnum, filenum);
wprintw(window, "Accepted file transfer %u. Saving file as %d.%u.bin.\n", filenum, friendnum,
filenum);
else
wprintw(window, "File transfer failed.\n");
}

View File

@ -94,7 +94,8 @@ static void print_groupchat_help(ChatContext *ctx)
wattroff(ctx->history, COLOR_PAIR(CYAN));
}
static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int peernum, uint8_t *msg, uint16_t len)
static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int peernum,
uint8_t *msg, uint16_t len)
{
if (self->num != groupnum)
return;

View File

@ -360,17 +360,18 @@ void do_file_senders(Tox *m)
file_senders[i].nextpiece, file_senders[i].piecelen))
return;
file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1, tox_filedata_size(m, file_senders[i].friendnum),
file_senders[i].file);
file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1, tox_filedata_size(m,
file_senders[i].friendnum), file_senders[i].file);
if (file_senders[i].piecelen == 0) {
fclose(file_senders[i].file);
file_senders[i].file = NULL;
tox_file_sendcontrol(m, file_senders[i].friendnum, 0, file_senders[i].filenum, 3, 0, 0);
tox_file_sendcontrol(m, file_senders[i].friendnum, 0, file_senders[i].filenum,
3, 0, 0);
/* TODO: move this alert to chat window */
wprintw(prompt->window, "File '%s' successfuly sent to %s.\n", file_senders[i].filename,
file_senders[i].friendname);
wprintw(prompt->window, "File '%s' successfuly sent to %s.\n",
file_senders[i].filename, file_senders[i].friendname);
return;
}
}

View File

@ -40,6 +40,16 @@ struct tm *get_time(void)
return timeinfo;
}
/* Prints the time to given window */
void print_time(WINDOW *window)
{
struct tm *timeinfo = get_time();
wattron(window, COLOR_PAIR(CYAN));
wprintw(window, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
wattroff(window, COLOR_PAIR(CYAN));
}
/* check that the string has one non-space character */
int string_is_empty(char *string)
{
@ -95,13 +105,3 @@ char *wc_to_char(wchar_t ch)
return ret;
}
/* Prints the time to given window */
void print_time(WINDOW *window)
{
struct tm *timeinfo = get_time();
wattron(window, COLOR_PAIR(CYAN));
wprintw(window, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
wattroff(window, COLOR_PAIR(CYAN));
}

View File

@ -8,6 +8,9 @@ unsigned char *hex_string_to_bin(char hex_string[]);
/* get the current local time */
struct tm *get_time(void);
/* Prints the time to given window */
void print_time(WINDOW *window);
/* check that the string has one non-space character */
int string_is_empty(char *string);
@ -16,6 +19,3 @@ uint8_t *wcs_to_char(wchar_t *string);
/* convert a wide char to null terminated string */
char *wc_to_char(wchar_t ch);
/* Prints the time to window w */
void print_time(WINDOW *window);

View File

@ -118,7 +118,8 @@ void on_friendadded(Tox *m, int friendnumber)
wprintw(prompt->window, "\nCould not store Tox data\n");
}
void on_groupmessage(Tox *m, int groupnumber, int peernumber, uint8_t *message, uint16_t length, void *userdata)
void on_groupmessage(Tox *m, int groupnumber, int peernumber, uint8_t *message, uint16_t length,
void *userdata)
{
int i;
@ -162,7 +163,8 @@ void on_file_control (Tox *m, int friendnumber, uint8_t receive_send, uint8_t fi
}
}
void on_file_data(Tox *m, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
void on_file_data(Tox *m, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length,
void *userdata)
{
int i;