mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Messenger add friends functions error code fixes.
Removed unknown error. norequest function now returns proper error codes.
This commit is contained in:
parent
3f11d106da
commit
99ee86b865
|
@ -194,7 +194,7 @@ static int32_t init_new_friend(Messenger *m, const uint8_t *real_pk, uint8_t sta
|
||||||
int friendcon_id = new_friend_connection(m->fr_c, real_pk);
|
int friendcon_id = new_friend_connection(m->fr_c, real_pk);
|
||||||
|
|
||||||
if (friendcon_id == -1)
|
if (friendcon_id == -1)
|
||||||
return FAERR_UNKNOWN;
|
return FAERR_NOMEM;
|
||||||
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ static int32_t init_new_friend(Messenger *m, const uint8_t *real_pk, uint8_t sta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FAERR_UNKNOWN;
|
return FAERR_NOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -241,7 +241,6 @@ static int32_t init_new_friend(Messenger *m, const uint8_t *real_pk, uint8_t sta
|
||||||
* return FAERR_NOMESSAGE if no message (message length must be >= 1 byte).
|
* return FAERR_NOMESSAGE if no message (message length must be >= 1 byte).
|
||||||
* return FAERR_OWNKEY if user's own key.
|
* return FAERR_OWNKEY if user's own key.
|
||||||
* return FAERR_ALREADYSENT if friend request already sent or already a friend.
|
* return FAERR_ALREADYSENT if friend request already sent or already a friend.
|
||||||
* return FAERR_UNKNOWN for unknown error.
|
|
||||||
* return FAERR_BADCHECKSUM if bad checksum in address.
|
* return FAERR_BADCHECKSUM if bad checksum in address.
|
||||||
* return FAERR_SETNEWNOSPAM if the friend was already there but the nospam was different.
|
* return FAERR_SETNEWNOSPAM if the friend was already there but the nospam was different.
|
||||||
* (the nospam for that friend was set to the new one).
|
* (the nospam for that friend was set to the new one).
|
||||||
|
@ -303,21 +302,15 @@ int32_t m_addfriend(Messenger *m, const uint8_t *address, const uint8_t *data, u
|
||||||
int32_t m_addfriend_norequest(Messenger *m, const uint8_t *real_pk)
|
int32_t m_addfriend_norequest(Messenger *m, const uint8_t *real_pk)
|
||||||
{
|
{
|
||||||
if (getfriend_id(m, real_pk) != -1)
|
if (getfriend_id(m, real_pk) != -1)
|
||||||
return -1;
|
return FAERR_ALREADYSENT;
|
||||||
|
|
||||||
if (!public_key_valid(real_pk))
|
if (!public_key_valid(real_pk))
|
||||||
return -1;
|
return FAERR_BADCHECKSUM;
|
||||||
|
|
||||||
if (id_equal(real_pk, m->net_crypto->self_public_key))
|
if (id_equal(real_pk, m->net_crypto->self_public_key))
|
||||||
return -1;
|
return FAERR_OWNKEY;
|
||||||
|
|
||||||
int32_t ret = init_new_friend(m, real_pk, FRIEND_CONFIRMED);
|
return init_new_friend(m, real_pk, FRIEND_CONFIRMED);
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove a friend.
|
/* Remove a friend.
|
||||||
|
|
|
@ -95,7 +95,6 @@ enum {
|
||||||
FAERR_NOMESSAGE = -2,
|
FAERR_NOMESSAGE = -2,
|
||||||
FAERR_OWNKEY = -3,
|
FAERR_OWNKEY = -3,
|
||||||
FAERR_ALREADYSENT = -4,
|
FAERR_ALREADYSENT = -4,
|
||||||
FAERR_UNKNOWN = -5,
|
|
||||||
FAERR_BADCHECKSUM = -6,
|
FAERR_BADCHECKSUM = -6,
|
||||||
FAERR_SETNEWNOSPAM = -7,
|
FAERR_SETNEWNOSPAM = -7,
|
||||||
FAERR_NOMEM = -8
|
FAERR_NOMEM = -8
|
||||||
|
@ -329,7 +328,6 @@ void getaddress(const Messenger *m, uint8_t *address);
|
||||||
* return -2 if no message (message length must be >= 1 byte).
|
* return -2 if no message (message length must be >= 1 byte).
|
||||||
* return -3 if user's own key.
|
* return -3 if user's own key.
|
||||||
* return -4 if friend request already sent or already a friend.
|
* return -4 if friend request already sent or already a friend.
|
||||||
* return -5 for unknown error.
|
|
||||||
* return -6 if bad checksum in address.
|
* return -6 if bad checksum in address.
|
||||||
* return -7 if the friend was already there but the nospam was different.
|
* return -7 if the friend was already there but the nospam was different.
|
||||||
* (the nospam for that friend was set to the new one).
|
* (the nospam for that friend was set to the new one).
|
||||||
|
@ -340,7 +338,10 @@ int32_t m_addfriend(Messenger *m, const uint8_t *address, const uint8_t *data, u
|
||||||
|
|
||||||
/* Add a friend without sending a friendrequest.
|
/* Add a friend without sending a friendrequest.
|
||||||
* return the friend number if success.
|
* return the friend number if success.
|
||||||
* return -1 if failure.
|
* return -3 if user's own key.
|
||||||
|
* return -4 if friend request already sent or already a friend.
|
||||||
|
* return -6 if bad checksum in address.
|
||||||
|
* return -8 if increasing the friend list size fails.
|
||||||
*/
|
*/
|
||||||
int32_t m_addfriend_norequest(Messenger *m, const uint8_t *real_pk);
|
int32_t m_addfriend_norequest(Messenger *m, const uint8_t *real_pk);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user