当前位置: 首页>>代码示例>>C++>>正文


C++ ToxId::toString方法代码示例

本文整理汇总了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();
}
开发者ID:SkyzohKey,项目名称:qTox,代码行数:27,代码来源:addfriendform.cpp

示例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)));
}
开发者ID:mpxc,项目名称:qTox,代码行数:10,代码来源:profileform.cpp

示例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);
}
开发者ID:Artom-Kozincev,项目名称:qTox,代码行数:35,代码来源:toxme.cpp

示例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;
}
开发者ID:Pik-9,项目名称:qTox,代码行数:28,代码来源:core.cpp

示例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();
}
开发者ID:mpxc,项目名称:qTox,代码行数:25,代码来源:core.cpp

示例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);
}
开发者ID:1KoT1,项目名称:qTox,代码行数:16,代码来源:toxme.cpp

示例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);
    }
}
开发者ID:Doom032,项目名称:qTox,代码行数:16,代码来源:settings.cpp

示例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);
    }
}
开发者ID:Doom032,项目名称:qTox,代码行数:16,代码来源:settings.cpp


注:本文中的ToxId::toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。