summaryrefslogtreecommitdiff
path: root/core/Messenger.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/Messenger.h')
-rw-r--r--core/Messenger.h38
1 files changed, 32 insertions, 6 deletions
diff --git a/core/Messenger.h b/core/Messenger.h
index 20b38caa..8940aadd 100644
--- a/core/Messenger.h
+++ b/core/Messenger.h
@@ -60,6 +60,22 @@ extern "C" {
60/* don't assume MAX_USERSTATUS_LENGTH will stay at 128, it may be increased 60/* don't assume MAX_USERSTATUS_LENGTH will stay at 128, it may be increased
61 to an absurdly large number later */ 61 to an absurdly large number later */
62 62
63/* USERSTATUS_KIND
64 * Represents the different kinds of userstatus
65 * someone can have.
66 * More on this later... */
67
68typedef enum {
69 USERSTATUS_KIND_RETAIN = (uint8_t)0, /* This is a special value that must not be returned by
70 * m_get_userstatus_kind. You can pass it into m_set_userstatus
71 * to keep the current USERSTATUS_KIND. */
72 USERSTATUS_KIND_ONLINE, /* Recommended representation: Green. */
73 USERSTATUS_KIND_AWAY, /* Recommended representation: Orange, or yellow. */
74 USERSTATUS_KIND_BUSY, /* Recommended representation: Red. */
75 USERSTATUS_KIND_OFFLINE, /* Recommended representation: Grey, semi-transparent. */
76 USERSTATUS_KIND_INVALID,
77} USERSTATUS_KIND;
78
63/* 79/*
64 * add a friend 80 * add a friend
65 * set the data that will be sent along with friend request 81 * set the data that will be sent along with friend request
@@ -70,7 +86,7 @@ extern "C" {
70 * return -2 if no message (message length must be >= 1 byte) 86 * return -2 if no message (message length must be >= 1 byte)
71 * return -3 if user's own key 87 * return -3 if user's own key
72 * return -4 if friend request already sent or already a friend 88 * return -4 if friend request already sent or already a friend
73 * return -5 for unknown error 89 * return -5 for unknown error
74 */ 90 */
75int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length); 91int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length);
76 92
@@ -114,7 +130,7 @@ int m_sendmessage(int friendnumber, uint8_t *message, uint32_t length);
114int setname(uint8_t *name, uint16_t length); 130int setname(uint8_t *name, uint16_t length);
115 131
116/* get our nickname 132/* get our nickname
117 put it in name 133 put it in name
118 return the length of the name*/ 134 return the length of the name*/
119uint16_t getself_name(uint8_t *name); 135uint16_t getself_name(uint8_t *name);
120 136
@@ -128,7 +144,8 @@ int getname(int friendnumber, uint8_t *name);
128/* set our user status 144/* set our user status
129 you are responsible for freeing status after 145 you are responsible for freeing status after
130 returns 0 on success, -1 on failure */ 146 returns 0 on success, -1 on failure */
131int m_set_userstatus(uint8_t *status, uint16_t length); 147int m_set_userstatus(USERSTATUS_KIND kind, uint8_t *status, uint16_t length);
148int m_set_userstatus_kind(USERSTATUS_KIND kind);
132 149
133/* return the length of friendnumber's user status, 150/* return the length of friendnumber's user status,
134 including null 151 including null
@@ -136,8 +153,17 @@ int m_set_userstatus(uint8_t *status, uint16_t length);
136int m_get_userstatus_size(int friendnumber); 153int m_get_userstatus_size(int friendnumber);
137 154
138/* copy friendnumber's userstatus into buf, truncating if size is over maxlen 155/* copy friendnumber's userstatus into buf, truncating if size is over maxlen
139 get the size you need to allocate from m_get_userstatus_size */ 156 get the size you need to allocate from m_get_userstatus_size
157 The self variant will copy our own userstatus. */
140int m_copy_userstatus(int friendnumber, uint8_t *buf, uint32_t maxlen); 158int m_copy_userstatus(int friendnumber, uint8_t *buf, uint32_t maxlen);
159int m_copy_self_userstatus(uint8_t *buf, uint32_t maxlen);
160
161/* Return one of USERSTATUS_KIND values, except USERSTATUS_KIND_RETAIN.
162 * Values unknown to your application should be represented as USERSTATUS_KIND_ONLINE.
163 * As above, the self variant will return our own USERSTATUS_KIND.
164 * If friendnumber is invalid, this shall return USERSTATUS_KIND_INVALID. */
165USERSTATUS_KIND m_get_userstatus_kind(int friendnumber);
166USERSTATUS_KIND m_get_self_userstatus_kind(void);
141 167
142/* set the function that will be executed when a friend request is received. 168/* set the function that will be executed when a friend request is received.
143 function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */ 169 function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */
@@ -153,9 +179,9 @@ void m_callback_friendmessage(void (*function)(int, uint8_t *, uint16_t));
153void m_callback_namechange(void (*function)(int, uint8_t *, uint16_t)); 179void m_callback_namechange(void (*function)(int, uint8_t *, uint16_t));
154 180
155/* set the callback for user status changes 181/* set the callback for user status changes
156 function(int friendnumber, uint8_t *newstatus, uint16_t length) 182 function(int friendnumber, USERSTATUS_KIND kind, uint8_t *newstatus, uint16_t length)
157 you are not responsible for freeing newstatus */ 183 you are not responsible for freeing newstatus */
158void m_callback_userstatus(void (*function)(int, uint8_t *, uint16_t)); 184void m_callback_userstatus(void (*function)(int, USERSTATUS_KIND, uint8_t *, uint16_t));
159 185
160/* run this at startup 186/* run this at startup
161 returns 0 if no connection problems 187 returns 0 if no connection problems