From cd0518a45c9354d06bb3eed42b5267eea27d5ca2 Mon Sep 17 00:00:00 2001 From: Astonex Date: Wed, 31 Jul 2013 00:13:31 +0100 Subject: Update Messenger.c Offer more meaningful returns so appropriate actions can be taken by the GUI. --- core/Messenger.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/Messenger.c b/core/Messenger.c index 272c5fa7..641dbf8e 100644 --- a/core/Messenger.c +++ b/core/Messenger.c @@ -99,16 +99,19 @@ int getclient_id(int friend_id, uint8_t *client_id) client_id is the client id of the friend data is the data and length is the length returns the friend number if success - return -1 if failure. */ + return -1 if key length is wrong. + return -2 if user's own key + return -3 if already a friend + return -4 for other*/ int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length) { if (length == 0 || length >= (MAX_DATA_SIZE - crypto_box_PUBLICKEYBYTES - crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES)) return -1; if (memcmp(client_id, self_public_key, crypto_box_PUBLICKEYBYTES) == 0) - return -1; + return -2; if (getfriend_id(client_id) != -1) - return -1; + return -3; uint32_t i; for (i = 0; i <= numfriends; ++i) { if(friendlist[i].status == 0) { @@ -126,7 +129,7 @@ int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length) return i; } } - return -1; + return -4; } int m_addfriend_norequest(uint8_t * client_id) -- cgit v1.2.3