1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(persistence): pass by reference to const

This commit is contained in:
PafXUS 2016-06-18 07:49:40 +03:00
parent e3278853d5
commit e852ed92f6
No known key found for this signature in database
GPG Key ID: EE6F45227424D1B7
8 changed files with 14 additions and 14 deletions

View File

@ -312,7 +312,7 @@ bool RawDatabase::remove()
}
QString RawDatabase::deriveKey(QString password)
QString RawDatabase::deriveKey(const QString &password)
{
if (password.isEmpty())
return {};

View File

@ -89,7 +89,7 @@ protected slots:
protected:
/// Derives a 256bit key from the password and returns it hex-encoded
static QString deriveKey(QString password);
static QString deriveKey(const QString &password);
/// Extracts a variant from one column of a result row depending on the column type
static QVariant extractData(sqlite3_stmt* stmt, int col);

View File

@ -37,7 +37,7 @@
QVector<QString> Profile::profiles;
Profile::Profile(QString name, QString password, bool isNewProfile)
Profile::Profile(QString name, const QString &password, bool isNewProfile)
: name{name}, password{password},
newProfile{isNewProfile}, isRemoved{false}
{
@ -65,7 +65,7 @@ Profile::Profile(QString name, QString password, bool isNewProfile)
QObject::connect(coreThread, &QThread::started, core, &Core::start);
}
Profile* Profile::loadProfile(QString name, QString password)
Profile* Profile::loadProfile(QString name, const QString &password)
{
if (ProfileLocker::hasLock())
{
@ -594,7 +594,7 @@ void Profile::restartCore()
QMetaObject::invokeMethod(core, "reset");
}
void Profile::setPassword(QString newPassword)
void Profile::setPassword(const QString &newPassword)
{
QByteArray avatar = loadAvatarData(core->getSelfId().publicKey);
QString oldPassword = password;

View File

@ -38,7 +38,7 @@ class Profile
public:
/// Locks and loads an existing profile and create the associate Core* instance
/// Returns a nullptr on error, for example if the profile is already in use
static Profile* loadProfile(QString name, QString password = QString());
static Profile* loadProfile(QString name, const QString &password = QString());
/// Creates a new profile and the associated Core* instance
/// If password is not empty, the profile will be encrypted
/// Returns a nullptr on error, for example if the profile already exists
@ -54,7 +54,7 @@ public:
bool isEncrypted() const; ///< Returns true if we have a password set (doesn't check the actual file on disk)
bool checkPassword(); ///< Checks whether the password is valid
QString getPassword() const;
void setPassword(QString newPassword); ///< Changes the encryption password and re-saves everything with it
void setPassword(const QString &newPassword); ///< Changes the encryption password and re-saves everything with it
const TOX_PASS_KEY& getPasskey() const;
QByteArray loadToxSave(); ///< Loads the profile's .tox save from file, unencrypted
@ -93,7 +93,7 @@ public:
static bool isEncrypted(QString name); ///< Returns false on error. Checks the actual file on disk.
private:
Profile(QString name, QString password, bool newProfile);
Profile(QString name, const QString &password, bool newProfile);
/// Lists all the files in the config dir with a given extension
/// Pass the raw extension, e.g. "jpeg" not ".jpeg".
static QVector<QString> getFilesByExt(QString extension);

View File

@ -492,7 +492,7 @@ void Settings::savePersonal(Profile* profile)
savePersonal(profile->getName(), profile->getPassword());
}
void Settings::savePersonal(QString profileName, QString password)
void Settings::savePersonal(QString profileName, const QString &password)
{
if (QThread::currentThread() != settingsThread)
return (void) QMetaObject::invokeMethod(&getInstance(), "savePersonal",
@ -924,7 +924,7 @@ QString Settings::getToxmePass() const
return toxmePass;
}
void Settings::setToxmePass(QString pass)
void Settings::setToxmePass(const QString &pass)
{
QMutexLocker locker{&bigLock};
toxmePass = pass;

View File

@ -129,7 +129,7 @@ public:
void setToxmePriv(bool priv);
QString getToxmePass() const;
void setToxmePass(QString pass);
void setToxmePass(const QString &pass);
void setAutoSaveEnabled(bool newValue);
bool getAutoSaveEnabled() const;
@ -344,7 +344,7 @@ private:
Settings& operator=(const Settings&) = delete;
private slots:
void savePersonal(QString profileName, QString password);
void savePersonal(QString profileName, const QString &password);
private:
bool loaded;

View File

@ -72,7 +72,7 @@ QDataStream& readStream(QDataStream& dataStream, QByteArray& data)
return dataStream;
}
SettingsSerializer::SettingsSerializer(QString filePath, QString password)
SettingsSerializer::SettingsSerializer(QString filePath, const QString &password)
: path{filePath}, password{password},
group{-1}, array{-1}, arrayIndex{-1}
{

View File

@ -34,7 +34,7 @@
class SettingsSerializer
{
public:
SettingsSerializer(QString filePath, QString password=QString());
SettingsSerializer(QString filePath, const QString &password=QString());
static bool isSerializedFormat(QString filePath); ///< Check if the file is serialized settings. False on error.