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:
parent
21f8e7f398
commit
13c5de5531
@ -129,8 +129,7 @@ static struct line_info *line_info_ret_queue(struct history *hst)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* creates new line_info line and puts it in the queue.
|
/* creates new line_info line and puts it in the queue. */
|
||||||
SYS_MSG lines may contain an arbitrary number of arguments for string formatting */
|
|
||||||
void line_info_add(ToxWindow *self, char *timestr, char *name1, char *name2, uint8_t type, uint8_t bold,
|
void line_info_add(ToxWindow *self, char *timestr, char *name1, char *name2, uint8_t type, uint8_t bold,
|
||||||
uint8_t colour, const char *msg, ...)
|
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)
|
void line_info_print(ToxWindow *self)
|
||||||
{
|
{
|
||||||
ChatContext *ctx = self->chatwin;
|
ChatContext *ctx = self->chatwin;
|
||||||
@ -315,7 +316,7 @@ void line_info_print(ToxWindow *self)
|
|||||||
if (line->msg[0] == '>')
|
if (line->msg[0] == '>')
|
||||||
wattroff(win, COLOR_PAIR(GREEN));
|
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));
|
wattron(win, COLOR_PAIR(RED));
|
||||||
wprintw(win, " x", line->msg);
|
wprintw(win, " x", line->msg);
|
||||||
wattroff(win, COLOR_PAIR(RED));
|
wattroff(win, COLOR_PAIR(RED));
|
||||||
@ -340,7 +341,7 @@ void line_info_print(ToxWindow *self)
|
|||||||
wprintw(win, "* %s %s", line->name1, line->msg);
|
wprintw(win, "* %s %s", line->name1, line->msg);
|
||||||
wattroff(win, COLOR_PAIR(YELLOW));
|
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));
|
wattron(win, COLOR_PAIR(RED));
|
||||||
wprintw(win, " x", line->msg);
|
wprintw(win, " x", line->msg);
|
||||||
wattroff(win, COLOR_PAIR(RED));
|
wattroff(win, COLOR_PAIR(RED));
|
||||||
|
@ -72,8 +72,7 @@ struct history {
|
|||||||
int queue_sz;
|
int queue_sz;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* creates new line_info line and puts it in the queue.
|
/* creates new line_info line and puts it in the queue. */
|
||||||
SYS_MSG lines may contain an arbitrary number of arguments for string formatting */
|
|
||||||
void line_info_add(ToxWindow *self, char *timestr, char *name1, char *name2, uint8_t type, uint8_t bold,
|
void line_info_add(ToxWindow *self, char *timestr, char *name1, char *name2, uint8_t type, uint8_t bold,
|
||||||
uint8_t colour, const char *msg, ...);
|
uint8_t colour, const char *msg, ...);
|
||||||
|
|
||||||
|
@ -86,6 +86,8 @@ void init_logging_session(char *name, const char *key, struct chatlog *log)
|
|||||||
fprintf(log->file, "\n*** NEW SESSION ***\n\n");
|
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)
|
void write_to_log(const char *msg, const char *name, struct chatlog *log, bool event)
|
||||||
{
|
{
|
||||||
if (!log->log_on)
|
if (!log->log_on)
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
#ifndef _log_h
|
#ifndef _log_h
|
||||||
#define _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 {
|
struct chatlog {
|
||||||
FILE *file;
|
FILE *file;
|
||||||
uint64_t lastwrite;
|
uint64_t lastwrite;
|
||||||
|
@ -73,18 +73,19 @@ static void cqueue_mark_read(ToxWindow *self, uint32_t id, uint8_t type)
|
|||||||
struct line_info *line = self->chatwin->hst->line_end;
|
struct line_info *line = self->chatwin->hst->line_end;
|
||||||
|
|
||||||
while (line) {
|
while (line) {
|
||||||
if (line->id == id) {
|
if (line->id != id) {
|
||||||
line->type = type == OUT_ACTION ? OUT_ACTION_READ : OUT_MSG_READ;
|
line = line->prev;
|
||||||
|
continue;
|
||||||
if (line->noread_flag == true) {
|
|
||||||
line->len -= 2;
|
|
||||||
line->noread_flag = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
line = line->prev;
|
line->type = type == OUT_ACTION ? OUT_ACTION_READ : OUT_MSG_READ;
|
||||||
|
|
||||||
|
if (line->noread_flag == true) {
|
||||||
|
line->len -= 2;
|
||||||
|
line->noread_flag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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. */
|
/* 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 chat_queue *q = self->chatwin->cqueue;
|
||||||
struct cqueue_msg *msg = q->root;
|
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;
|
uint32_t receipt = 0;
|
||||||
|
|
||||||
if (msg->type == OUT_MSG)
|
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
|
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->last_send_try = curtime;
|
||||||
msg->receipt = receipt;
|
msg->receipt = receipt;
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CQUEUE_TRY_SEND_INTERVAL 5
|
|
||||||
|
|
||||||
struct cqueue_msg {
|
struct cqueue_msg {
|
||||||
char message[MAX_STR_SIZE];
|
char message[MAX_STR_SIZE];
|
||||||
int len;
|
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);
|
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. */
|
/* 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. */
|
/* 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);
|
void cqueue_remove(ToxWindow *self, struct chat_queue *q, uint32_t receipt);
|
||||||
|
@ -588,7 +588,7 @@ void *thread_cqueue(void *data)
|
|||||||
ToxWindow *toxwin = get_window_ptr(i);
|
ToxWindow *toxwin = get_window_ptr(i);
|
||||||
|
|
||||||
if (toxwin != NULL && toxwin->is_chat && tox_get_friend_connection_status(m, toxwin->num) == 1)
|
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);
|
pthread_mutex_unlock(&Winthread.lock);
|
||||||
|
Loading…
Reference in New Issue
Block a user