summaryrefslogtreecommitdiff
path: root/protocols/Tox/libtox/src/toxcore/Messenger.h
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Tox/libtox/src/toxcore/Messenger.h')
-rw-r--r--protocols/Tox/libtox/src/toxcore/Messenger.h45
1 files changed, 22 insertions, 23 deletions
diff --git a/protocols/Tox/libtox/src/toxcore/Messenger.h b/protocols/Tox/libtox/src/toxcore/Messenger.h
index 8279815277..cace3340b2 100644
--- a/protocols/Tox/libtox/src/toxcore/Messenger.h
+++ b/protocols/Tox/libtox/src/toxcore/Messenger.h
@@ -10,15 +10,25 @@
#ifndef C_TOXCORE_TOXCORE_MESSENGER_H
#define C_TOXCORE_TOXCORE_MESSENGER_H
+#include "DHT.h"
+#include "TCP_client.h"
#include "TCP_server.h"
#include "announce.h"
+#include "attributes.h"
+#include "crypto_core.h"
#include "forwarding.h"
#include "friend_connection.h"
#include "friend_requests.h"
#include "group_announce.h"
#include "group_common.h"
#include "logger.h"
+#include "mem.h"
+#include "mono_time.h"
#include "net_crypto.h"
+#include "network.h"
+#include "onion.h"
+#include "onion_announce.h"
+#include "onion_client.h"
#include "state.h"
#define MAX_NAME_LENGTH 128
@@ -29,7 +39,6 @@
/* This cannot be bigger than 256 */
#define MAX_CONCURRENT_FILE_PIPES 256
-
#define FRIEND_ADDRESS_SIZE (CRYPTO_PUBLIC_KEY_SIZE + sizeof(uint32_t) + sizeof(uint16_t))
typedef enum Message_Type {
@@ -41,7 +50,7 @@ typedef enum Message_Type {
#ifndef MESSENGER_DEFINED
#define MESSENGER_DEFINED
typedef struct Messenger Messenger;
-#endif // MESSENGER_DEFINED
+#endif /* MESSENGER_DEFINED */
// Returns the size of the data
typedef uint32_t m_state_size_cb(const Messenger *m);
@@ -69,6 +78,7 @@ typedef struct Messenger_Options {
bool hole_punching_enabled;
bool local_discovery_enabled;
bool dht_announcements_enabled;
+ bool groups_persistence_enabled;
logger_cb *log_callback;
void *log_context;
@@ -78,7 +88,6 @@ typedef struct Messenger_Options {
uint8_t state_plugins_length;
} Messenger_Options;
-
struct Receipts {
uint32_t packet_num;
uint32_t msg_id;
@@ -108,7 +117,6 @@ typedef enum Friend_Add_Error {
FAERR_NOMEM = -8,
} Friend_Add_Error;
-
/** Default start timeout in seconds between friend requests. */
#define FRIENDREQUEST_TIMEOUT 5
@@ -166,7 +174,6 @@ typedef enum Filekind {
FILEKIND_AVATAR,
} Filekind;
-
typedef void m_self_connection_status_cb(Messenger *m, Onion_Connection_Status connection_status, void *user_data);
typedef void m_friend_status_cb(Messenger *m, uint32_t friend_number, unsigned int status, void *user_data);
typedef void m_friend_connection_status_cb(Messenger *m, uint32_t friend_number, unsigned int connection_status,
@@ -194,14 +201,14 @@ typedef void m_friend_lossy_packet_cb(Messenger *m, uint32_t friend_number, uint
typedef void m_friend_lossless_packet_cb(Messenger *m, uint32_t friend_number, uint8_t packet_id, const uint8_t *data,
size_t length, void *user_data);
typedef void m_friend_connectionstatuschange_internal_cb(Messenger *m, uint32_t friend_number,
- uint8_t connection_status, void *user_data);
+ bool is_online, void *user_data);
typedef void m_conference_invite_cb(Messenger *m, uint32_t friend_number, const uint8_t *cookie, uint16_t length,
void *user_data);
-typedef void m_group_invite_cb(const Messenger *m, uint32_t friendnumber, const uint8_t *data, size_t length,
- const uint8_t *group_name, size_t group_name_length, void *userdata);
+typedef void m_group_invite_cb(const Messenger *m, uint32_t friend_number, const uint8_t *invite_data, size_t length,
+ const uint8_t *group_name, size_t group_name_length, void *user_data);
typedef void m_msi_packet_cb(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length,
void *user_data);
-typedef int m_lossy_rtp_packet_cb(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t len, void *object);
+typedef int m_lossy_rtp_packet_cb(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object);
typedef struct RTP_Packet_Handler {
m_lossy_rtp_packet_cb *function;
@@ -245,6 +252,7 @@ typedef struct Friend {
struct Messenger {
Logger *log;
Mono_Time *mono_time;
+ const Memory *mem;
const Random *rng;
const Network *ns;
@@ -296,7 +304,7 @@ struct Messenger {
m_friend_connectionstatuschange_internal_cb *friend_connectionstatuschange_internal;
void *friend_connectionstatuschange_internal_userdata;
- struct Group_Chats *conferences_object; /* Set by new_groupchats()*/
+ struct Group_Chats *conferences_object;
m_conference_invite_cb *conference_invite;
m_group_invite_cb *group_invite;
@@ -358,7 +366,6 @@ void getaddress(const Messenger *m, uint8_t *address);
non_null()
int32_t m_addfriend(Messenger *m, const uint8_t *address, const uint8_t *data, uint16_t length);
-
/** @brief Add a friend without sending a friendrequest.
* @return the friend number if success.
* @retval -3 if user's own key.
@@ -448,7 +455,6 @@ non_null(1, 4) nullable(6)
int m_send_message_generic(Messenger *m, int32_t friendnumber, uint8_t type, const uint8_t *message, uint32_t length,
uint32_t *message_id);
-
/** @brief Set the name and name_length of a friend.
*
* name must be a string of maximum MAX_NAME_LENGTH length.
@@ -539,7 +545,6 @@ non_null() int m_copy_self_statusmessage(const Messenger *m, uint8_t *buf);
non_null() uint8_t m_get_userstatus(const Messenger *m, int32_t friendnumber);
non_null() uint8_t m_get_self_userstatus(const Messenger *m);
-
/** @brief returns timestamp of last time friendnumber was seen online or 0 if never seen.
* if friendnumber is invalid this function will return UINT64_MAX.
*/
@@ -613,7 +618,6 @@ non_null() void m_callback_connectionstatus(Messenger *m, m_friend_connection_st
non_null() void m_callback_connectionstatus_internal_av(
Messenger *m, m_friend_connectionstatuschange_internal_cb *function, void *userdata);
-
/** @brief Set the callback for typing changes. */
non_null() void m_callback_core_connection(Messenger *m, m_self_connection_status_cb *function);
@@ -628,7 +632,6 @@ void m_callback_conference_invite(Messenger *m, m_conference_invite_cb *function
non_null(1) nullable(2)
void m_callback_group_invite(Messenger *m, m_group_invite_cb *function);
-
/** @brief Send a conference invite packet.
*
* return true on success
@@ -645,16 +648,13 @@ bool send_conference_invite_packet(const Messenger *m, int32_t friendnumber, con
* return true on success
*/
non_null()
-bool send_group_invite_packet(const Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length);
-
+bool send_group_invite_packet(const Messenger *m, uint32_t friendnumber, const uint8_t *packet, uint16_t length);
/*** FILE SENDING */
-
/** @brief Set the callback for file send requests. */
non_null() void callback_file_sendrequest(Messenger *m, m_file_recv_cb *function);
-
/** @brief Set the callback for file control requests. */
non_null() void callback_file_control(Messenger *m, m_file_recv_control_cb *function);
@@ -664,7 +664,6 @@ non_null() void callback_file_data(Messenger *m, m_file_recv_chunk_cb *function)
/** @brief Set the callback for file request chunk. */
non_null() void callback_file_reqchunk(Messenger *m, m_file_chunk_request_cb *function);
-
/** @brief Copy the file transfer file id to file_id
*
* @retval 0 on success.
@@ -779,7 +778,6 @@ non_null() void custom_lossy_packet_registerhandler(Messenger *m, m_friend_lossy
non_null()
int m_send_custom_lossy_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length);
-
/** @brief Set handlers for custom lossless packets. */
non_null()
void custom_lossless_packet_registerhandler(Messenger *m, m_friend_lossless_packet_cb *lossless_packethandler);
@@ -813,7 +811,8 @@ typedef enum Messenger_Error {
* if error is not NULL it will be set to one of the values in the enum above.
*/
non_null()
-Messenger *new_messenger(Mono_Time *mono_time, const Random *rng, const Network *ns, Messenger_Options *options, Messenger_Error *error);
+Messenger *new_messenger(Mono_Time *mono_time, const Memory *mem, const Random *rng, const Network *ns,
+ Messenger_Options *options, Messenger_Error *error);
/** @brief Run this before closing shop.
*
@@ -888,4 +887,4 @@ uint32_t copy_friendlist(const Messenger *m, uint32_t *out_list, uint32_t list_s
non_null()
bool m_is_receiving_file(Messenger *m);
-#endif
+#endif /* C_TOXCORE_TOXCORE_MESSENGER_H */