From c2fb803ad5d3fdfeebd3fa2d61cb2cc3d68d2930 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Sat, 13 Jul 2013 17:44:43 -0400 Subject: Added conversion from friend_id to client_id --- core/Messenger.c | 19 +++++++++++++++++++ core/Messenger.h | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/core/Messenger.c b/core/Messenger.c index 8236c117..65a73876 100644 --- a/core/Messenger.c +++ b/core/Messenger.c @@ -66,6 +66,25 @@ int getfriend_id(uint8_t * client_id) return -1; } +//copies the public key associated to that friend id into client_id buffer. +//make sure that client_id is of size CLIENT_ID_SIZE. +//returns 0 if success +//return -1 if failure. +int getclient_id(int friend_id, uint8_t * client_id) +{ + if(friendnumber >= numfriends || friendnumber < 0) + { + return -1; + } + + if(friendlist[friend_id].status > 0) + { + memcpy(client_id, friendlist[friend_id].client_id, CLIENT_ID_SIZE); + return 0; + } + return -1; +} + //add a friend //set the data that will be sent along with friend request diff --git a/core/Messenger.h b/core/Messenger.h index d7e101b2..679df989 100644 --- a/core/Messenger.h +++ b/core/Messenger.h @@ -49,6 +49,12 @@ int m_addfriend_norequest(uint8_t * client_id); //return -1 if no such friend int getfriend_id(uint8_t * client_id); +//copies the public key associated to that friend id into client_id buffer. +//make sure that client_id is of size CLIENT_ID_SIZE. +//returns 0 if success +//return -1 if failure. +int getclient_id(int friend_id, uint8_t * client_id) + //remove a friend int m_delfriend(int friendnumber); -- cgit v1.2.3