diff options
Diffstat (limited to 'core/Messenger.h')
-rw-r--r-- | core/Messenger.h | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/core/Messenger.h b/core/Messenger.h index 0b8aa7aa..c89d0f52 100644 --- a/core/Messenger.h +++ b/core/Messenger.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* Messenger.h | 1 | /* Messenger.h |
2 | * | 2 | * |
3 | * An implementation of a simple text chat only messenger on the tox network core. | 3 | * An implementation of a simple text chat only messenger on the tox network core. |
4 | * | 4 | * |
5 | * NOTE: All the text in the messages must be encoded using UTF-8 | 5 | * NOTE: All the text in the messages must be encoded using UTF-8 |
6 | 6 | ||
7 | Copyright (C) 2013 Tox project All Rights Reserved. | 7 | Copyright (C) 2013 Tox project All Rights Reserved. |
@@ -24,12 +24,16 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | 26 | ||
27 | #ifndef MESSENGER_H | 27 | #ifndef MESSENGER_H |
28 | #define MESSENGER_H | 28 | #define MESSENGER_H |
29 | 29 | ||
30 | #include "net_crypto.h" | 30 | #include "net_crypto.h" |
31 | #include "DHT.h" | 31 | #include "DHT.h" |
32 | 32 | ||
33 | #define MAX_NAME_LENGTH 128 | ||
34 | #define MAX_USERSTATUS_LENGTH 128 | ||
35 | // don't assume MAX_USERSTATUS_LENGTH will stay at 128, it may be increased | ||
36 | // to an absurdly large number later | ||
33 | 37 | ||
34 | //add a friend | 38 | //add a friend |
35 | //set the data that will be sent along with friend request | 39 | //set the data that will be sent along with friend request |
@@ -85,6 +89,20 @@ int setname(uint8_t * name, uint16_t length); | |||
85 | //return -1 if failure | 89 | //return -1 if failure |
86 | int getname(int friendnumber, uint8_t * name); | 90 | int getname(int friendnumber, uint8_t * name); |
87 | 91 | ||
92 | // set our user status | ||
93 | // you are responsible for freeing status after | ||
94 | // returns 0 on success, -1 on failure | ||
95 | int m_set_userstatus(uint8_t *status, uint16_t length); | ||
96 | |||
97 | // return the length of friendnumber's user status, | ||
98 | // including null | ||
99 | // pass it into malloc | ||
100 | int m_get_userstatus_size(int friendnumber); | ||
101 | |||
102 | // copy friendnumber's userstatus into buf, truncating if size is over maxlen | ||
103 | // get the size you need to allocate from m_get_userstatus_size | ||
104 | int m_copy_userstatus(int friendnumber, uint8_t * buf, uint32_t maxlen); | ||
105 | |||
88 | //set the function that will be executed when a friend request is received. | 106 | //set the function that will be executed when a friend request is received. |
89 | //function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) | 107 | //function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) |
90 | void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t)); | 108 | void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t)); |
@@ -94,6 +112,15 @@ void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t)); | |||
94 | //function format is: function(int friendnumber, uint8_t * message, uint32_t length) | 112 | //function format is: function(int friendnumber, uint8_t * message, uint32_t length) |
95 | void m_callback_friendmessage(void (*function)(int, uint8_t *, uint16_t)); | 113 | void m_callback_friendmessage(void (*function)(int, uint8_t *, uint16_t)); |
96 | 114 | ||
115 | // set the callback for name changes | ||
116 | // function(int friendnumber, uint8_t *newname, uint16_t length) | ||
117 | // you are not responsible for freeing newname | ||
118 | void m_callback_namechange(void (*function)(int, uint8_t *, uint16_t)); | ||
119 | |||
120 | // set the callback for user status changes | ||
121 | // function(int friendnumber, uint8_t *newstatus, uint16_t length) | ||
122 | // you are not responsible for freeing newstatus | ||
123 | void m_callback_userstatus(void (*function)(int, uint8_t *, uint16_t)); | ||
97 | 124 | ||
98 | //run this at startup | 125 | //run this at startup |
99 | void initMessenger(); | 126 | void initMessenger(); |