From 200af0fd492ba4bdc120a0fc18934c8b9c84a7c2 Mon Sep 17 00:00:00 2001 From: tux3 Date: Sat, 25 Apr 2015 22:07:12 +0200 Subject: [PATCH] Better error messages for friend requests --- src/core/core.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index 733730250..b1f24a67c 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -561,7 +561,15 @@ void Core::requestFriendship(const QString& friendAddress, const QString& messag { const QString userId = friendAddress.mid(0, TOX_PUBLIC_KEY_SIZE * 2); - if (hasFriendWithAddress(friendAddress)) + if (message.isEmpty()) + { + emit failedToAddFriend(userId, QString(tr("You need to write a message with you request"))); + } + else if (message.size() > TOX_MAX_FRIEND_REQUEST_LENGTH) + { + emit failedToAddFriend(userId, QString(tr("Your message is too long!"))); + } + else if (hasFriendWithAddress(friendAddress)) { emit failedToAddFriend(userId, QString(tr("Friend is already added"))); }