summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAstonex <softukitu@gmail.com>2013-07-31 00:13:31 +0100
committerAstonex <softukitu@gmail.com>2013-07-31 00:13:31 +0100
commitcd0518a45c9354d06bb3eed42b5267eea27d5ca2 (patch)
treead62b73ab480b61159525595dc11f5c361a1539b /core
parentd97db7fcb89c5561b58d5c7a552b511e4cf16046 (diff)
Update Messenger.c
Offer more meaningful returns so appropriate actions can be taken by the GUI.
Diffstat (limited to 'core')
-rw-r--r--core/Messenger.c11
1 files 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)
99 client_id is the client id of the friend 99 client_id is the client id of the friend
100 data is the data and length is the length 100 data is the data and length is the length
101 returns the friend number if success 101 returns the friend number if success
102 return -1 if failure. */ 102 return -1 if key length is wrong.
103 return -2 if user's own key
104 return -3 if already a friend
105 return -4 for other*/
103int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length) 106int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length)
104{ 107{
105 if (length == 0 || length >= 108 if (length == 0 || length >=
106 (MAX_DATA_SIZE - crypto_box_PUBLICKEYBYTES - crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES)) 109 (MAX_DATA_SIZE - crypto_box_PUBLICKEYBYTES - crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES))
107 return -1; 110 return -1;
108 if (memcmp(client_id, self_public_key, crypto_box_PUBLICKEYBYTES) == 0) 111 if (memcmp(client_id, self_public_key, crypto_box_PUBLICKEYBYTES) == 0)
109 return -1; 112 return -2;
110 if (getfriend_id(client_id) != -1) 113 if (getfriend_id(client_id) != -1)
111 return -1; 114 return -3;
112 uint32_t i; 115 uint32_t i;
113 for (i = 0; i <= numfriends; ++i) { 116 for (i = 0; i <= numfriends; ++i) {
114 if(friendlist[i].status == 0) { 117 if(friendlist[i].status == 0) {
@@ -126,7 +129,7 @@ int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length)
126 return i; 129 return i;
127 } 130 }
128 } 131 }
129 return -1; 132 return -4;
130} 133}
131 134
132int m_addfriend_norequest(uint8_t * client_id) 135int m_addfriend_norequest(uint8_t * client_id)