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

Merge pull request #3411

PafXUS (1):
      fix(persistence): pass by reference to const
This commit is contained in:
sudden6 2016-07-08 00:07:44 +02:00
commit 06475b7424
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
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()) if (password.isEmpty())
return {}; return {};

View File

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

View File

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

View File

@ -38,7 +38,7 @@ class Profile
public: public:
/// Locks and loads an existing profile and create the associate Core* instance /// 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 /// 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 /// Creates a new profile and the associated Core* instance
/// If password is not empty, the profile will be encrypted /// If password is not empty, the profile will be encrypted
/// Returns a nullptr on error, for example if the profile already exists /// 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 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 bool checkPassword(); ///< Checks whether the password is valid
QString getPassword() const; 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; const TOX_PASS_KEY& getPasskey() const;
QByteArray loadToxSave(); ///< Loads the profile's .tox save from file, unencrypted 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. static bool isEncrypted(QString name); ///< Returns false on error. Checks the actual file on disk.
private: 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 /// Lists all the files in the config dir with a given extension
/// Pass the raw extension, e.g. "jpeg" not ".jpeg". /// Pass the raw extension, e.g. "jpeg" not ".jpeg".
static QVector<QString> getFilesByExt(QString extension); static QVector<QString> getFilesByExt(QString extension);

View File

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

View File

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

View File

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

View File

@ -34,7 +34,7 @@
class SettingsSerializer class SettingsSerializer
{ {
public: 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. static bool isSerializedFormat(QString filePath); ///< Check if the file is serialized settings. False on error.