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

increase time between message send retries

This commit is contained in:
Jfreegman 2014-09-10 16:18:37 -04:00
parent 21f8e7f398
commit 13c5de5531
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
7 changed files with 26 additions and 25 deletions

View File

@ -129,8 +129,7 @@ static struct line_info *line_info_ret_queue(struct history *hst)
return ret;
}
/* creates new line_info line and puts it in the queue.
SYS_MSG lines may contain an arbitrary number of arguments for string formatting */
/* creates new line_info line and puts it in the queue. */
void line_info_add(ToxWindow *self, char *timestr, char *name1, char *name2, uint8_t type, uint8_t bold,
uint8_t colour, const char *msg, ...)
{
@ -257,6 +256,8 @@ static void line_info_check_queue(ToxWindow *self)
}
}
#define NOREAD_FLAG_TIMEOUT 5 /* seconds before a sent message with no read receipt is flagged as unread */
void line_info_print(ToxWindow *self)
{
ChatContext *ctx = self->chatwin;
@ -315,7 +316,7 @@ void line_info_print(ToxWindow *self)
if (line->msg[0] == '>')
wattroff(win, COLOR_PAIR(GREEN));
if (type == OUT_MSG && timed_out(line->timestamp, get_unix_time(), CQUEUE_TRY_SEND_INTERVAL)) {
if (type == OUT_MSG && timed_out(line->timestamp, get_unix_time(), NOREAD_FLAG_TIMEOUT)) {
wattron(win, COLOR_PAIR(RED));
wprintw(win, " x", line->msg);
wattroff(win, COLOR_PAIR(RED));
@ -340,7 +341,7 @@ void line_info_print(ToxWindow *self)
wprintw(win, "* %s %s", line->name1, line->msg);
wattroff(win, COLOR_PAIR(YELLOW));
if (type == OUT_ACTION && timed_out(line->timestamp, get_unix_time(), CQUEUE_TRY_SEND_INTERVAL)) {
if (type == OUT_ACTION && timed_out(line->timestamp, get_unix_time(), NOREAD_FLAG_TIMEOUT)) {
wattron(win, COLOR_PAIR(RED));
wprintw(win, " x", line->msg);
wattroff(win, COLOR_PAIR(RED));

View File

@ -72,8 +72,7 @@ struct history {
int queue_sz;
};
/* creates new line_info line and puts it in the queue.
SYS_MSG lines may contain an arbitrary number of arguments for string formatting */
/* creates new line_info line and puts it in the queue. */
void line_info_add(ToxWindow *self, char *timestr, char *name1, char *name2, uint8_t type, uint8_t bold,
uint8_t colour, const char *msg, ...);

View File

@ -86,6 +86,8 @@ void init_logging_session(char *name, const char *key, struct chatlog *log)
fprintf(log->file, "\n*** NEW SESSION ***\n\n");
}
#define LOG_FLUSH_LIMIT 2 /* limits calls to fflush to a max of one per LOG_FLUSH_LIMIT seconds */
void write_to_log(const char *msg, const char *name, struct chatlog *log, bool event)
{
if (!log->log_on)

View File

@ -23,8 +23,6 @@
#ifndef _log_h
#define _log_h
#define LOG_FLUSH_LIMIT 2 /* limits calls to fflush(logfile) to a max of one per LOG_FLUSH_LIMIT seconds */
struct chatlog {
FILE *file;
uint64_t lastwrite;

View File

@ -73,7 +73,11 @@ static void cqueue_mark_read(ToxWindow *self, uint32_t id, uint8_t type)
struct line_info *line = self->chatwin->hst->line_end;
while (line) {
if (line->id == id) {
if (line->id != id) {
line = line->prev;
continue;
}
line->type = type == OUT_ACTION ? OUT_ACTION_READ : OUT_MSG_READ;
if (line->noread_flag == true) {
@ -83,9 +87,6 @@ static void cqueue_mark_read(ToxWindow *self, uint32_t id, uint8_t type)
return;
}
line = line->prev;
}
}
/* removes message with matching receipt from queue and updates line to show the message was received. */
@ -118,8 +119,10 @@ void cqueue_remove(ToxWindow *self, struct chat_queue *q, uint32_t receipt)
}
}
#define CQUEUE_TRY_SEND_INTERVAL 10
/* Tries to send the oldest unsent message in queue. */
void cqueue_try_send(ToxWindow *self, Tox *m, int32_t friendnum)
void cqueue_try_send(ToxWindow *self, Tox *m)
{
struct chat_queue *q = self->chatwin->cqueue;
struct cqueue_msg *msg = q->root;
@ -134,9 +137,9 @@ void cqueue_try_send(ToxWindow *self, Tox *m, int32_t friendnum)
uint32_t receipt = 0;
if (msg->type == OUT_MSG)
receipt = tox_send_message(m, friendnum, (uint8_t *) msg->message, msg->len);
receipt = tox_send_message(m, self->num, (uint8_t *) msg->message, msg->len);
else
receipt = tox_send_action(m, friendnum, (uint8_t *) msg->message, msg->len);
receipt = tox_send_action(m, self->num, (uint8_t *) msg->message, msg->len);
msg->last_send_try = curtime;
msg->receipt = receipt;

View File

@ -20,8 +20,6 @@
*
*/
#define CQUEUE_TRY_SEND_INTERVAL 5
struct cqueue_msg {
char message[MAX_STR_SIZE];
int len;
@ -42,7 +40,7 @@ void cqueue_cleanup(struct chat_queue *q);
void cqueue_add(struct chat_queue *q, const char *msg, int len, uint8_t type, uint32_t line_id);
/* Tries to send the oldest unsent message in queue. */
void cqueue_try_send(ToxWindow *self, Tox *m, int32_t friendnum);
void cqueue_try_send(ToxWindow *self, Tox *m);
/* removes message with matching receipt from queue and updates line to show the message was received. */
void cqueue_remove(ToxWindow *self, struct chat_queue *q, uint32_t receipt);

View File

@ -588,7 +588,7 @@ void *thread_cqueue(void *data)
ToxWindow *toxwin = get_window_ptr(i);
if (toxwin != NULL && toxwin->is_chat && tox_get_friend_connection_status(m, toxwin->num) == 1)
cqueue_try_send(toxwin, m, toxwin->num);
cqueue_try_send(toxwin, m);
}
pthread_mutex_unlock(&Winthread.lock);