diff options
author | Sean Qureshi <stqism@risingstormgames.com> | 2013-08-08 03:07:41 -0700 |
---|---|---|
committer | Sean Qureshi <stqism@risingstormgames.com> | 2013-08-08 03:07:41 -0700 |
commit | 4d0cce2f69b4a4f99b694e65d6c5ccaf38ef57b8 (patch) | |
tree | e300f13a4a0b86e9d1670c0ebc75bbeebc09fa02 /core/Messenger.h | |
parent | 1bbdd9d2dbbb0a0a7ae056699c487df00c55579e (diff) | |
parent | 225f74e844299c405b744a9d03f4fcc0430b430a (diff) |
Merge https://github.com/irungentoo/ProjectTox-Core
Diffstat (limited to 'core/Messenger.h')
-rw-r--r-- | core/Messenger.h | 63 |
1 files changed, 29 insertions, 34 deletions
diff --git a/core/Messenger.h b/core/Messenger.h index f0444b91..d2fa8945 100644 --- a/core/Messenger.h +++ b/core/Messenger.h | |||
@@ -36,10 +36,11 @@ extern "C" { | |||
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #define MAX_NAME_LENGTH 128 | 38 | #define MAX_NAME_LENGTH 128 |
39 | #define MAX_USERSTATUS_LENGTH 128 | 39 | #define MAX_STATUSMESSAGE_LENGTH 128 |
40 | 40 | ||
41 | #define PACKET_ID_NICKNAME 48 | 41 | #define PACKET_ID_NICKNAME 48 |
42 | #define PACKET_ID_USERSTATUS 49 | 42 | #define PACKET_ID_STATUSMESSAGE 49 |
43 | #define PACKET_ID_USERSTATUS 50 | ||
43 | #define PACKET_ID_RECEIPT 65 | 44 | #define PACKET_ID_RECEIPT 65 |
44 | #define PACKET_ID_MESSAGE 64 | 45 | #define PACKET_ID_MESSAGE 64 |
45 | 46 | ||
@@ -58,24 +59,18 @@ extern "C" { | |||
58 | #define FAERR_ALREADYSENT -4 | 59 | #define FAERR_ALREADYSENT -4 |
59 | #define FAERR_UNKNOWN -5 | 60 | #define FAERR_UNKNOWN -5 |
60 | 61 | ||
61 | /* don't assume MAX_USERSTATUS_LENGTH will stay at 128, it may be increased | 62 | /* don't assume MAX_STATUSMESSAGE_LENGTH will stay at 128, it may be increased |
62 | to an absurdly large number later */ | 63 | to an absurdly large number later */ |
63 | 64 | ||
64 | /* USERSTATUS_KIND | 65 | /* USERSTATUS |
65 | * Represents the different kinds of userstatus | 66 | * Represents userstatuses someone can have. */ |
66 | * someone can have. | ||
67 | * More on this later... */ | ||
68 | 67 | ||
69 | typedef enum { | 68 | typedef enum { |
70 | USERSTATUS_KIND_RETAIN = (uint8_t)0, /* This is a special value that must not be returned by | 69 | USERSTATUS_NONE, |
71 | * m_get_userstatus_kind. You can pass it into m_set_userstatus | 70 | USERSTATUS_AWAY, |
72 | * to keep the current USERSTATUS_KIND. */ | 71 | USERSTATUS_BUSY, |
73 | USERSTATUS_KIND_ONLINE, /* Recommended representation: Green. */ | 72 | USERSTATUS_INVALID |
74 | USERSTATUS_KIND_AWAY, /* Recommended representation: Orange, or yellow. */ | 73 | } USERSTATUS; |
75 | USERSTATUS_KIND_BUSY, /* Recommended representation: Red. */ | ||
76 | USERSTATUS_KIND_OFFLINE, /* Recommended representation: Grey, semi-transparent. */ | ||
77 | USERSTATUS_KIND_INVALID, | ||
78 | } USERSTATUS_KIND; | ||
79 | 74 | ||
80 | /* | 75 | /* |
81 | * add a friend | 76 | * add a friend |
@@ -150,26 +145,26 @@ int getname(int friendnumber, uint8_t *name); | |||
150 | /* set our user status | 145 | /* set our user status |
151 | you are responsible for freeing status after | 146 | you are responsible for freeing status after |
152 | returns 0 on success, -1 on failure */ | 147 | returns 0 on success, -1 on failure */ |
153 | int m_set_userstatus(USERSTATUS_KIND kind, uint8_t *status, uint16_t length); | 148 | int m_set_statusmessage(uint8_t *status, uint16_t length); |
154 | int m_set_userstatus_kind(USERSTATUS_KIND kind); | 149 | int m_set_userstatus(USERSTATUS status); |
155 | 150 | ||
156 | /* return the length of friendnumber's user status, | 151 | /* return the length of friendnumber's status message, |
157 | including null | 152 | including null |
158 | pass it into malloc */ | 153 | pass it into malloc */ |
159 | int m_get_userstatus_size(int friendnumber); | 154 | int m_get_statusmessage_size(int friendnumber); |
160 | 155 | ||
161 | /* copy friendnumber's userstatus into buf, truncating if size is over maxlen | 156 | /* copy friendnumber's status message into buf, truncating if size is over maxlen |
162 | get the size you need to allocate from m_get_userstatus_size | 157 | get the size you need to allocate from m_get_statusmessage_size |
163 | The self variant will copy our own userstatus. */ | 158 | The self variant will copy our own status message. */ |
164 | int m_copy_userstatus(int friendnumber, uint8_t *buf, uint32_t maxlen); | 159 | int m_copy_statusmessage(int friendnumber, uint8_t *buf, uint32_t maxlen); |
165 | int m_copy_self_userstatus(uint8_t *buf, uint32_t maxlen); | 160 | int m_copy_self_statusmessage(uint8_t *buf, uint32_t maxlen); |
166 | 161 | ||
167 | /* Return one of USERSTATUS_KIND values, except USERSTATUS_KIND_RETAIN. | 162 | /* Return one of USERSTATUS values. |
168 | * Values unknown to your application should be represented as USERSTATUS_KIND_ONLINE. | 163 | * Values unknown to your application should be represented as USERSTATUS_NONE. |
169 | * As above, the self variant will return our own USERSTATUS_KIND. | 164 | * As above, the self variant will return our own USERSTATUS. |
170 | * If friendnumber is invalid, this shall return USERSTATUS_KIND_INVALID. */ | 165 | * If friendnumber is invalid, this shall return USERSTATUS_INVALID. */ |
171 | USERSTATUS_KIND m_get_userstatus_kind(int friendnumber); | 166 | USERSTATUS m_get_userstatus(int friendnumber); |
172 | USERSTATUS_KIND m_get_self_userstatus_kind(void); | 167 | USERSTATUS m_get_self_userstatus(void); |
173 | 168 | ||
174 | /* Sets whether we send read receipts for friendnumber. | 169 | /* Sets whether we send read receipts for friendnumber. |
175 | * This function is not lazy, and it will fail if yesno is not (0 or 1).*/ | 170 | * This function is not lazy, and it will fail if yesno is not (0 or 1).*/ |
@@ -188,10 +183,10 @@ void m_callback_friendmessage(void (*function)(int, uint8_t *, uint16_t)); | |||
188 | you are not responsible for freeing newname */ | 183 | you are not responsible for freeing newname */ |
189 | void m_callback_namechange(void (*function)(int, uint8_t *, uint16_t)); | 184 | void m_callback_namechange(void (*function)(int, uint8_t *, uint16_t)); |
190 | 185 | ||
191 | /* set the callback for user status changes | 186 | /* set the callback for status message changes |
192 | function(int friendnumber, USERSTATUS_KIND kind, uint8_t *newstatus, uint16_t length) | 187 | function(int friendnumber, uint8_t *newstatus, uint16_t length) |
193 | you are not responsible for freeing newstatus */ | 188 | you are not responsible for freeing newstatus */ |
194 | void m_callback_userstatus(void (*function)(int, USERSTATUS_KIND, uint8_t *, uint16_t)); | 189 | void m_callback_statusmessage(void (*function)(int, uint8_t *, uint16_t)); |
195 | 190 | ||
196 | /* set the callback for read receipts | 191 | /* set the callback for read receipts |
197 | function(int friendnumber, uint32_t receipt) | 192 | function(int friendnumber, uint32_t receipt) |