summaryrefslogtreecommitdiff
path: root/core/Messenger.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/Messenger.h')
-rw-r--r--core/Messenger.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/core/Messenger.h b/core/Messenger.h
index aa9611a4..48e14cf7 100644
--- a/core/Messenger.h
+++ b/core/Messenger.h
@@ -38,6 +38,8 @@ extern "C" {
38#define MAX_NAME_LENGTH 128 38#define MAX_NAME_LENGTH 128
39#define MAX_STATUSMESSAGE_LENGTH 128 39#define MAX_STATUSMESSAGE_LENGTH 128
40 40
41#define FRIEND_ADDRESS_SIZE (crypto_box_PUBLICKEYBYTES + sizeof(uint32_t) + sizeof(uint16_t))
42
41#define PACKET_ID_NICKNAME 48 43#define PACKET_ID_NICKNAME 48
42#define PACKET_ID_STATUSMESSAGE 49 44#define PACKET_ID_STATUSMESSAGE 49
43#define PACKET_ID_USERSTATUS 50 45#define PACKET_ID_USERSTATUS 50
@@ -89,6 +91,7 @@ typedef struct {
89 uint16_t info_size; /* length of the info */ 91 uint16_t info_size; /* length of the info */
90 uint32_t message_id; /* a semi-unique id used in read receipts */ 92 uint32_t message_id; /* a semi-unique id used in read receipts */
91 uint8_t receives_read_receipts; /* shall we send read receipts to this person? */ 93 uint8_t receives_read_receipts; /* shall we send read receipts to this person? */
94 uint32_t friendrequest_nospam; /*The nospam number used in the friend request*/
92} Friend; 95} Friend;
93 96
94typedef struct Messenger { 97typedef struct Messenger {
@@ -134,9 +137,17 @@ typedef struct Messenger {
134} Messenger; 137} Messenger;
135 138
136/* 139/*
140 * returns a FRIEND_ADDRESS_SIZE byte address to give to others.
141 * format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)]
142 *
143 * TODO: add checksum.
144 */
145void getaddress(Messenger *m, uint8_t *address);
146
147/*
137 * add a friend 148 * add a friend
138 * set the data that will be sent along with friend request 149 * set the data that will be sent along with friend request
139 * client_id is the client id of the friend 150 * address is the address of the friend (returned by getaddress) it must be FRIEND_ADDRESS_SIZE bytes. TODO: add checksum.
140 * data is the data and length is the length 151 * data is the data and length is the length
141 * returns the friend number if success 152 * returns the friend number if success
142 * return -1 if message length is too long 153 * return -1 if message length is too long
@@ -145,7 +156,7 @@ typedef struct Messenger {
145 * return -4 if friend request already sent or already a friend 156 * return -4 if friend request already sent or already a friend
146 * return -5 for unknown error 157 * return -5 for unknown error
147 */ 158 */
148int m_addfriend(Messenger *m, uint8_t *client_id, uint8_t *data, uint16_t length); 159int m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length);
149 160
150 161
151/* add a friend without sending a friendrequest. 162/* add a friend without sending a friendrequest.