Example #1
0
/**
 * @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;
}
Example #2
0
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);
}
Example #3
0
/**
 * @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);
    }
}
Example #4
0
/**
 * @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);
}
Example #5
0
/**
 * @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;
}