本文整理汇总了C++中ToxId::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ ToxId::toString方法的具体用法?C++ ToxId::toString怎么用?C++ ToxId::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToxId
的用法示例。
在下文中一共展示了ToxId::toString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onSendTriggered
void AddFriendForm::onSendTriggered()
{
QString id = toxId.text().trimmed();
if (!ToxId::isToxId(id))
{
ToxId toxId = Toxme::lookup(id); // Try Toxme
if (toxId.toString().isEmpty())
{
GUI::showWarning(tr("Couldn't add friend"),
tr("This Tox ID does not exist", "Toxme error"));
return;
}
id = toxId.toString();
}
deleteFriendRequest(id);
if (id.toUpper() == Core::getInstance()->getSelfId().toString().toUpper())
GUI::showWarning(tr("Couldn't add friend"),
tr("You can't add yourself as a friend!",
"When trying to add your own Tox ID as friend"));
else
emit friendRequested(id, getMessage());
this->toxId.clear();
this->message.clear();
}
示例2: setToxId
void ProfileForm::setToxId(const ToxId& id)
{
toxId->setText(id.toString());
toxId->setCursorPosition(0);
delete qr;
qr = new QRWidget();
qr->setQRData("tox:" + id.toString());
bodyUI->qrCode->setPixmap(QPixmap::fromImage(qr->getImage()->scaledToWidth(150)));
}
示例3: createAddress
QString Toxme::createAddress(ExecCode &code, QString server, ToxId id, QString address,
bool keepPrivate, QString bio)
{
int privacy = keepPrivate ? 0 : 2;
// JSON injection ?
bio.replace('\\',"\\\\");
bio.replace('"',"\"");
address.replace('\\',"\\\\");
address.replace('"',"\"");
bio = bio.trimmed();
address = address.trimmed();
server = server.trimmed();
if (!server.contains("://"))
server = "https://" + server;
const QString payload{"{\"tox_id\":\""+id.toString()+"\","
"\"name\":\""+address+"\","
"\"privacy\":"+QString().setNum(privacy)+","
"\"bio\":\""+bio+"\","
"\"timestamp\":"+QString().setNum(time(0))+"}"};
QString pubkeyUrl = server + "/pk";
QString apiUrl = server + "/api";
QNetworkReply::NetworkError error = QNetworkReply::NoError;
QByteArray encrypted = prepareEncryptedJson(pubkeyUrl, 1, payload);
QByteArray response = makeJsonRequest(apiUrl, encrypted, error);
code = extractError(response);
if ((code != Ok && code != Updated) || error != QNetworkReply::NoError)
return QString();
return getPass(response, code);
}
示例4: getPeerName
QString Core::getPeerName(const ToxId& id) const
{
QString name;
CUserId cid(id.toString());
uint32_t friendId = tox_friend_by_public_key(tox, (uint8_t*)cid.data(), nullptr);
if (friendId == std::numeric_limits<uint32_t>::max())
{
qWarning() << "getPeerName: No such peer";
return name;
}
const size_t nameSize = tox_friend_get_name_size(tox, friendId, nullptr);
if (nameSize == SIZE_MAX)
return name;
uint8_t* cname = new uint8_t[nameSize<TOX_MAX_NAME_LENGTH ? TOX_MAX_NAME_LENGTH : nameSize];
if (!tox_friend_get_name(tox, friendId, cname, nullptr))
{
qWarning() << "getPeerName: Can't get name of friend "+QString().setNum(friendId);
delete[] cname;
return name;
}
name = CString::toString(cname, nameSize);
delete[] cname;
return name;
}
示例5: 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();
}
示例6: deleteAddress
int Toxme::deleteAddress(QString server, ToxId id)
{
const QString payload{"{\"public_key\":\""+id.toString().left(64)+"\","
"\"timestamp\":"+QString().setNum(time(0))+"}"};
server = server.trimmed();
if (!server.contains("://"))
server = "https://" + server;
QString pubkeyUrl = server + "/pk";
QString apiUrl = server + "/api";
QNetworkReply::NetworkError error = QNetworkReply::NoError;
QByteArray response = makeJsonRequest(apiUrl, prepareEncryptedJson(pubkeyUrl, 2, payload), error);
return extractError(response);
}
示例7: setContactNote
void Settings::setContactNote(const ToxId &id, const QString& note)
{
QMutexLocker locker{&bigLock};
auto it = friendLst.find(id.publicKey);
if (it != friendLst.end())
{
qDebug() << note;
it->note = note;
}
else
{
updateFriendAdress(id.toString());
setContactNote(id, note);
}
}
示例8: setAutoAcceptDir
void Settings::setAutoAcceptDir(const ToxId &id, const QString& dir)
{
QMutexLocker locker{&bigLock};
QString key = id.publicKey;
auto it = friendLst.find(key);
if (it != friendLst.end())
{
it->autoAcceptDir = dir;
}
else
{
updateFriendAdress(id.toString());
setAutoAcceptDir(id, dir);
}
}