From 9801eceaa4834798a9b879d353a455754e5fbf00 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Wed, 7 Aug 2013 17:01:31 -0400 Subject: Separated StatusMessage from UserStatus --- core/Messenger.h | 63 ++++++++++++++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 34 deletions(-) (limited to 'core/Messenger.h') diff --git a/core/Messenger.h b/core/Messenger.h index 8940aadd..aef652ff 100644 --- a/core/Messenger.h +++ b/core/Messenger.h @@ -36,10 +36,11 @@ extern "C" { #endif #define MAX_NAME_LENGTH 128 -#define MAX_USERSTATUS_LENGTH 128 +#define MAX_STATUSMESSAGE_LENGTH 128 #define PACKET_ID_NICKNAME 48 -#define PACKET_ID_USERSTATUS 49 +#define PACKET_ID_STATUSMESSAGE 49 +#define PACKET_ID_USERSTATUS 50 #define PACKET_ID_MESSAGE 64 /* status definitions */ @@ -57,24 +58,18 @@ extern "C" { #define FAERR_ALREADYSENT -4 #define FAERR_UNKNOWN -5 -/* don't assume MAX_USERSTATUS_LENGTH will stay at 128, it may be increased +/* don't assume MAX_STATUSMESSAGE_LENGTH will stay at 128, it may be increased to an absurdly large number later */ -/* USERSTATUS_KIND - * Represents the different kinds of userstatus - * someone can have. - * More on this later... */ +/* USERSTATUS + * Represents userstatuses someone can have. */ typedef enum { - USERSTATUS_KIND_RETAIN = (uint8_t)0, /* This is a special value that must not be returned by - * m_get_userstatus_kind. You can pass it into m_set_userstatus - * to keep the current USERSTATUS_KIND. */ - USERSTATUS_KIND_ONLINE, /* Recommended representation: Green. */ - USERSTATUS_KIND_AWAY, /* Recommended representation: Orange, or yellow. */ - USERSTATUS_KIND_BUSY, /* Recommended representation: Red. */ - USERSTATUS_KIND_OFFLINE, /* Recommended representation: Grey, semi-transparent. */ - USERSTATUS_KIND_INVALID, -} USERSTATUS_KIND; + USERSTATUS_NONE, + USERSTATUS_AWAY, + USERSTATUS_BUSY, + USERSTATUS_INVALID +} USERSTATUS; /* * add a friend @@ -144,26 +139,26 @@ int getname(int friendnumber, uint8_t *name); /* set our user status you are responsible for freeing status after returns 0 on success, -1 on failure */ -int m_set_userstatus(USERSTATUS_KIND kind, uint8_t *status, uint16_t length); -int m_set_userstatus_kind(USERSTATUS_KIND kind); +int m_set_statusmessage(uint8_t *status, uint16_t length); +int m_set_userstatus(USERSTATUS status); -/* return the length of friendnumber's user status, +/* return the length of friendnumber's status message, including null pass it into malloc */ -int m_get_userstatus_size(int friendnumber); +int m_get_statusmessage_size(int friendnumber); -/* copy friendnumber's userstatus into buf, truncating if size is over maxlen - get the size you need to allocate from m_get_userstatus_size - The self variant will copy our own userstatus. */ -int m_copy_userstatus(int friendnumber, uint8_t *buf, uint32_t maxlen); -int m_copy_self_userstatus(uint8_t *buf, uint32_t maxlen); +/* copy friendnumber's status message into buf, truncating if size is over maxlen + get the size you need to allocate from m_get_statusmessage_size + The self variant will copy our own status message. */ +int m_copy_statusmessage(int friendnumber, uint8_t *buf, uint32_t maxlen); +int m_copy_self_statusmessage(uint8_t *buf, uint32_t maxlen); -/* Return one of USERSTATUS_KIND values, except USERSTATUS_KIND_RETAIN. - * Values unknown to your application should be represented as USERSTATUS_KIND_ONLINE. - * As above, the self variant will return our own USERSTATUS_KIND. - * If friendnumber is invalid, this shall return USERSTATUS_KIND_INVALID. */ -USERSTATUS_KIND m_get_userstatus_kind(int friendnumber); -USERSTATUS_KIND m_get_self_userstatus_kind(void); +/* Return one of USERSTATUS values. + * Values unknown to your application should be represented as USERSTATUS_NONE. + * As above, the self variant will return our own USERSTATUS. + * If friendnumber is invalid, this shall return USERSTATUS_INVALID. */ +USERSTATUS m_get_userstatus(int friendnumber); +USERSTATUS m_get_self_userstatus(void); /* set the function that will be executed when a friend request is received. function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */ @@ -178,10 +173,10 @@ void m_callback_friendmessage(void (*function)(int, uint8_t *, uint16_t)); you are not responsible for freeing newname */ void m_callback_namechange(void (*function)(int, uint8_t *, uint16_t)); -/* set the callback for user status changes - function(int friendnumber, USERSTATUS_KIND kind, uint8_t *newstatus, uint16_t length) +/* set the callback for status message changes + function(int friendnumber, uint8_t *newstatus, uint16_t length) you are not responsible for freeing newstatus */ -void m_callback_userstatus(void (*function)(int, USERSTATUS_KIND, uint8_t *, uint16_t)); +void m_callback_statusmessage(void (*function)(int, uint8_t *, uint16_t)); /* run this at startup returns 0 if no connection problems -- cgit v1.2.3