2014-09-06 19:18:42 +02:00
|
|
|
/* message_queue.h
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Toxic All Rights Reserved.
|
|
|
|
*
|
|
|
|
* This file is part of Toxic.
|
|
|
|
*
|
|
|
|
* Toxic is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Toxic is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Toxic. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-09-23 03:24:45 +02:00
|
|
|
#ifndef MESSAGE_QUEUE_H
|
|
|
|
#define MESSAGE_QUEUE_H
|
|
|
|
|
2014-09-06 19:18:42 +02:00
|
|
|
struct cqueue_msg {
|
|
|
|
char message[MAX_STR_SIZE];
|
2015-03-28 07:56:54 +01:00
|
|
|
size_t len;
|
2014-09-06 19:18:42 +02:00
|
|
|
int line_id;
|
|
|
|
uint8_t type;
|
|
|
|
uint32_t receipt;
|
2014-09-07 08:43:53 +02:00
|
|
|
uint64_t last_send_try;
|
2014-09-06 19:18:42 +02:00
|
|
|
struct cqueue_msg *next;
|
2014-09-09 20:06:28 +02:00
|
|
|
struct cqueue_msg *prev;
|
2014-09-06 19:18:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct chat_queue {
|
|
|
|
struct cqueue_msg *root;
|
|
|
|
struct cqueue_msg *end;
|
|
|
|
};
|
|
|
|
|
|
|
|
void cqueue_cleanup(struct chat_queue *q);
|
2015-03-28 07:56:54 +01:00
|
|
|
void cqueue_add(struct chat_queue *q, const char *msg, size_t len, uint8_t type, uint32_t line_id);
|
2014-09-07 08:43:53 +02:00
|
|
|
|
2014-09-09 21:16:27 +02:00
|
|
|
/* Tries to send the oldest unsent message in queue. */
|
2014-09-10 22:18:37 +02:00
|
|
|
void cqueue_try_send(ToxWindow *self, Tox *m);
|
2014-09-07 08:43:53 +02:00
|
|
|
|
2014-09-11 07:36:33 +02:00
|
|
|
/* removes message with matching receipt from queue, writes to log and updates line to show the message was received. */
|
|
|
|
void cqueue_remove(ToxWindow *self, Tox *m, uint32_t receipt);
|
2014-09-23 03:24:45 +02:00
|
|
|
|
2015-03-28 07:56:54 +01:00
|
|
|
#endif /* #define MESSAGE_QUEUE_H */
|