本文整理汇总了C++中ToxId::getPublicKey方法的典型用法代码示例。如果您正苦于以下问题:C++ ToxId::getPublicKey方法的具体用法?C++ ToxId::getPublicKey怎么用?C++ ToxId::getPublicKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToxId
的用法示例。
在下文中一共展示了ToxId::getPublicKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: requestFriendship
void Core::requestFriendship(const ToxId& friendId, const QString& message)
{
ToxPk friendPk = friendId.getPublicKey();
QString errorMessage = getFriendRequestErrorMessage(friendId, message);
if (!errorMessage.isNull()) {
emit failedToAddFriend(friendPk, errorMessage);
profile.saveToxSave();
}
ToxString cMessage(message);
uint32_t friendNumber =
tox_friend_add(tox, friendId.getBytes(), cMessage.data(), cMessage.size(), nullptr);
if (friendNumber == std::numeric_limits<uint32_t>::max()) {
qDebug() << "Failed to request friendship";
emit failedToAddFriend(friendPk);
} else {
qDebug() << "Requested friendship of " << friendNumber;
Settings::getInstance().updateFriendAddress(friendId.toString());
emit friendAdded(friendNumber, friendPk);
emit requestSent(friendPk, message);
}
profile.saveToxSave();
}
示例2: getFriendRequestErrorMessage
/**
* @brief Checks that sending friendship request is correct and returns error message accordingly
* @param friendId Id of a friend which request is destined to
* @param message Friendship request message
* @return Returns empty string if sending request is correct, according error message otherwise
*/
QString Core::getFriendRequestErrorMessage(const ToxId& friendId, const QString& message) const
{
if (!friendId.isValid()) {
return tr("Invalid Tox ID", "Error while sending friendship request");
}
if (message.isEmpty()) {
return tr("You need to write a message with your request",
"Error while sending friendship request");
}
if (message.length() > TOX_MAX_FRIEND_REQUEST_LENGTH) {
return tr("Your message is too long!", "Error while sending friendship request");
}
if (hasFriendWithPublicKey(friendId.getPublicKey())) {
return tr("Friend is already added", "Error while sending friendship request");
}
return QString{};
}
示例3: getPublicKey
/**
* @brief Compares the inequality of the Public Key.
* @param other Tox ID to compare.
* @return True if both Tox IDs have different public keys, false otherwise.
*/
bool ToxId::operator!=(const ToxId& other) const
{
return getPublicKey() != other.getPublicKey();
}