qTox
Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
|
Handles all qTox internal paths. More...
#include <profile.h>
Public Slots | |
void | onRequestSent (const ToxPk &friendPk, const QString &message) |
Adds history message about friendship request attempt if history is enabled. More... | |
Signals | |
void | selfAvatarChanged (const QPixmap &pixmap) |
void | friendAvatarChanged (const ToxPk &friendPk, const QPixmap &pixmap) |
void | friendAvatarSet (const ToxPk &friendPk, const QPixmap &pixmap) |
void | friendAvatarRemoved (const ToxPk &friendPk) |
void | failedToStart () |
void | badProxy () |
void | coreChanged (Core &core) |
Public Member Functions | |
~Profile () | |
Core & | getCore () const |
QString | getName () const |
void | startCore () |
Starts the Core thread. More... | |
bool | isEncrypted () const |
Checks, if profile has a password. More... | |
QString | setPassword (const QString &newPassword) |
Changes the encryption password and re-saves everything with it. More... | |
const ToxEncrypt * | getPasskey () const |
QPixmap | loadAvatar () |
Get our avatar from cache. More... | |
QPixmap | loadAvatar (const ToxPk &owner) |
Get a contact's avatar from cache. More... | |
QByteArray | loadAvatarData (const ToxPk &owner) |
Get a contact's avatar from cache. More... | |
void | setAvatar (QByteArray pic) |
Sets our own avatar. More... | |
void | setFriendAvatar (const ToxPk &owner, QByteArray pic) |
Sets a friends avatar. More... | |
QByteArray | getAvatarHash (const ToxPk &owner) |
Get the tox hash of a cached avatar. More... | |
void | removeSelfAvatar () |
Removes our own avatar. More... | |
void | removeFriendAvatar (const ToxPk &owner) |
Removes friend avatar. More... | |
bool | isHistoryEnabled () |
Checks that the history is enabled in the settings, and loaded successfully for this profile. More... | |
History * | getHistory () |
Get chat history. More... | |
QStringList | remove () |
Removes the profile permanently. Updates the profiles vector. More... | |
bool | rename (QString newName) |
Tries to rename the profile. More... | |
Static Public Member Functions | |
static Profile * | loadProfile (const QString &name, const QString &password, Settings &settings, const QCommandLineParser *parser) |
Locks and loads an existing profile and creates the associate Core* instance. More... | |
static Profile * | createProfile (const QString &name, const QString &password, Settings &settings, const QCommandLineParser *parser) |
Creates a new profile and the associated Core* instance. More... | |
static const QStringList | getAllProfileNames () |
Scan for profile, automatically importing them if needed. More... | |
static bool | exists (QString name) |
static bool | isEncrypted (QString name) |
Checks if profile is encrypted. More... | |
static QString | getDbPath (const QString &profileName) |
Retrieves the path to the database file for a given profile. More... | |
Private Slots | |
void | loadDatabase (QString password) |
void | saveAvatar (const ToxPk &owner, const QByteArray &avatar) |
Save an avatar to cache. More... | |
void | removeAvatar (const ToxPk &owner) |
Removes a cached avatar. More... | |
void | onSaveToxSave () |
Saves the profile's .tox save, encrypted if needed. More... | |
void | onAvatarOfferReceived (uint32_t friendId, uint32_t fileId, const QByteArray &avatarHash, uint64_t filesize) |
Private Member Functions | |
Profile (const QString &name, std::unique_ptr< ToxEncrypt > passkey, Paths &paths, Settings &settings_) | |
QString | avatarPath (const ToxPk &owner, bool forceUnencrypted=false) |
Gets the path of the avatar file cached by this profile and corresponding to this owner ID. More... | |
bool | saveToxSave (QByteArray data) |
Write the .tox save, encrypted if needed. More... | |
void | initCore (const QByteArray &toxsave, Settings &s, bool isNewProfile) |
Static Private Member Functions | |
static QStringList | getFilesByExt (QString extension) |
Lists all the files in the config dir with a given extension. More... | |
Private Attributes | |
std::unique_ptr< AvatarBroadcaster > | avatarBroadcaster |
std::unique_ptr< Core > | core |
std::unique_ptr< CoreAV > | coreAv |
QString | name |
std::unique_ptr< ToxEncrypt > | passkey |
std::shared_ptr< RawDatabase > | database |
std::shared_ptr< History > | history |
bool | isRemoved |
True if the profile has been removed by remove(). More... | |
bool | encrypted = false |
std::unique_ptr< BootstrapNodeUpdater > | bootstrapNodes |
Paths & | paths |
Settings & | settings |
Static Private Attributes | |
static QStringList | profiles |
Handles all qTox internal paths.
Manages user profiles.
The qTox internal file layout starts at <BASE_PATH>
. This directory is platform specific and depends on if qTox runs in portable mode.
Example file layout for non-portable mode:
Example file layout for portable mode:
All qTox or Tox specific directories should be looked up through this module.
Profile::~Profile | ( | ) |
|
private |
|
private |
Gets the path of the avatar file cached by this profile and corresponding to this owner ID.
owner | Path to avatar of friend with this PK will returned. |
forceUnencrypted | If true, return the path to the plaintext file even if this is an encrypted profile. |
Definition at line 531 of file profile.cpp.
|
signal |
|
signal |
|
static |
Creates a new profile and the associated Core* instance.
name | Username. |
password | If password is not empty, the profile will be encrypted. |
Definition at line 355 of file profile.cpp.
|
static |
Definition at line 804 of file profile.cpp.
|
signal |
|
signal |
|
signal |
|
signal |
|
static |
Scan for profile, automatically importing them if needed.
Definition at line 414 of file profile.cpp.
QByteArray Profile::getAvatarHash | ( | const ToxPk & | owner | ) |
Get the tox hash of a cached avatar.
owner | Friend PK to get hash. |
Definition at line 747 of file profile.cpp.
Core & Profile::getCore | ( | ) | const |
|
static |
Retrieves the path to the database file for a given profile.
profileName | Profile name. |
Definition at line 985 of file profile.cpp.
|
staticprivate |
Lists all the files in the config dir with a given extension.
extension | Raw extension, e.g. "jpeg" not ".jpeg". |
Definition at line 395 of file profile.cpp.
History * Profile::getHistory | ( | ) |
Get chat history.
Definition at line 785 of file profile.cpp.
QString Profile::getName | ( | ) | const |
const ToxEncrypt * Profile::getPasskey | ( | ) | const |
|
private |
Definition at line 235 of file profile.cpp.
bool Profile::isEncrypted | ( | ) | const |
Checks, if profile has a password.
Definition at line 814 of file profile.cpp.
|
static |
Checks if profile is encrypted.
name | Profile name. |
Definition at line 825 of file profile.cpp.
bool Profile::isHistoryEnabled | ( | ) |
Checks that the history is enabled in the settings, and loaded successfully for this profile.
Definition at line 776 of file profile.cpp.
QPixmap Profile::loadAvatar | ( | ) |
Get our avatar from cache.
Definition at line 556 of file profile.cpp.
QPixmap Profile::loadAvatar | ( | const ToxPk & | owner | ) |
Get a contact's avatar from cache.
owner | Friend PK to load avatar. |
Definition at line 566 of file profile.cpp.
QByteArray Profile::loadAvatarData | ( | const ToxPk & | owner | ) |
Get a contact's avatar from cache.
owner | Friend PK to load avatar. |
Definition at line 590 of file profile.cpp.
|
privateslot |
Definition at line 616 of file profile.cpp.
|
static |
Locks and loads an existing profile and creates the associate Core* instance.
Definition at line 313 of file profile.cpp.
|
privateslot |
Definition at line 474 of file profile.cpp.
|
slot |
Adds history message about friendship request attempt if history is enabled.
friendPk | Pk of a friend which request is destined to |
message | Friendship request message |
Definition at line 704 of file profile.cpp.
|
privateslot |
Saves the profile's .tox save, encrypted if needed.
Definition at line 466 of file profile.cpp.
QStringList Profile::remove | ( | ) |
Removes the profile permanently. Updates the profiles vector.
Definition at line 847 of file profile.cpp.
|
privateslot |
Removes a cached avatar.
owner | Friend PK whose avater to delete. |
Definition at line 794 of file profile.cpp.
void Profile::removeFriendAvatar | ( | const ToxPk & | owner | ) |
Removes friend avatar.
Definition at line 766 of file profile.cpp.
void Profile::removeSelfAvatar | ( | ) |
Removes our own avatar.
Definition at line 758 of file profile.cpp.
bool Profile::rename | ( | QString | newName | ) |
Tries to rename the profile.
newName | New name for the profile. |
Definition at line 896 of file profile.cpp.
|
privateslot |
Save an avatar to cache.
pic | Picture to save. |
owner | PK of avatar owner. |
Definition at line 722 of file profile.cpp.
|
private |
Write the .tox save, encrypted if needed.
data | Byte array of profile save. |
Definition at line 487 of file profile.cpp.
|
signal |
void Profile::setAvatar | ( | QByteArray | pic | ) |
Sets our own avatar.
pic | Picture to use as avatar, if empty an Identicon will be used depending on settings |
Definition at line 648 of file profile.cpp.
void Profile::setFriendAvatar | ( | const ToxPk & | owner, |
QByteArray | pic | ||
) |
Sets a friends avatar.
pic | Picture to use as avatar, if empty an Identicon will be used depending on settings |
owner | pk of friend |
Definition at line 679 of file profile.cpp.
QString Profile::setPassword | ( | const QString & | newPassword | ) |
Changes the encryption password and re-saves everything with it.
newPassword | Password for encryption, if empty profile will be decrypted. |
oldPassword | Supply previous password if already encrypted or empty QString if not yet encrypted. |
Definition at line 934 of file profile.cpp.
void Profile::startCore | ( | ) |
Starts the Core thread.
Definition at line 443 of file profile.cpp.
|
private |
|
private |
|
private |
|
private |
|
private |