예제 #1
0
파일: profile.cpp 프로젝트: SkyzohKey/qTox
/**
 * @brief Get the tox hash of a cached avatar.
 * @param ownerId Friend ID to get hash.
 * @return Avatar tox hash.
 */
QByteArray Profile::getAvatarHash(const QString& ownerId)
{
    QByteArray pic = loadAvatarData(ownerId);
    QByteArray avatarHash(TOX_HASH_LENGTH, 0);
    tox_hash((uint8_t*)avatarHash.data(), (uint8_t*)pic.data(), pic.size());
    return avatarHash;
}
예제 #2
0
파일: profile.cpp 프로젝트: aszinovyev/qTox
void Profile::setPassword(QString newPassword)
{
    QList<HistoryKeeper::HistMessage> oldMessages = HistoryKeeper::exportMessagesDeleteFile();
    QByteArray avatar = loadAvatarData(core->getSelfId().publicKey);

    password = newPassword;
    passkey = *core->createPasskey(password);
    saveToxSave();

    HistoryKeeper::getInstance()->importMessages(oldMessages);
    Nexus::getDesktopGUI()->reloadHistory();
    saveAvatar(avatar, core->getSelfId().publicKey);
}
예제 #3
0
파일: profile.cpp 프로젝트: SkyzohKey/qTox
/**
 * @brief Changes the encryption password and re-saves everything with it
 * @param newPassword Password for encryption.
 */
void Profile::setPassword(const QString& newPassword)
{
    QByteArray avatar = loadAvatarData(core->getSelfId().publicKey);
    QString oldPassword = password;
    password = newPassword;
    passkey = *core->createPasskey(password);
    saveToxSave();

    if (database)
    {
        database->setPassword(newPassword);
    }

    Nexus::getDesktopGUI()->reloadHistory();
    saveAvatar(avatar, core->getSelfId().publicKey);

    QVector<uint32_t> friendList = core->getFriendList();
    QVectorIterator<uint32_t> i(friendList);
    while (i.hasNext())
    {
        QString friendPublicKey = core->getFriendPublicKey(i.next());
        saveAvatar(loadAvatarData(friendPublicKey,oldPassword),friendPublicKey);
    }
}
예제 #4
0
파일: profile.cpp 프로젝트: SkyzohKey/qTox
/**
 * @brief Get a contact's avatar from cache
 * @param ownerId Friend ID to load avatar.
 * @return Avatar as QByteArray.
 */
QByteArray Profile::loadAvatarData(const QString& ownerId)
{
  return loadAvatarData(ownerId, password);
}
예제 #5
0
파일: profile.cpp 프로젝트: SkyzohKey/qTox
/**
 * @brief Get a contact's avatar from cache.
 * @param ownerId Friend ID to load avatar.
 * @return Avatar as QPixmap.
 */
QPixmap Profile::loadAvatar(const QString& ownerId)
{
    QPixmap pic;
    pic.loadFromData(loadAvatarData(ownerId));
    return pic;
}