mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 22:23:24 +00:00
Fix usage of QString
1 - Pass QStrings by const-ref 2 - Don't initialize empty strings with "", they are empty by default 3 - Don't compare empty strings with "", use .isEmpty() 4 - don't append or prepend " ", use QChar(' ') 5 - don't compare QStrings with "constant string", use QLatin1String(" constant string" ) Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
8b7427c56d
commit
ccf29679ae
2 changed files with 10 additions and 10 deletions
|
@ -17,18 +17,18 @@ CloudStorageAuthenticate::CloudStorageAuthenticate(QObject *parent) :
|
|||
#define CLOUDBACKENDVERIFY CLOUDURL + "/verify"
|
||||
#define CLOUDBACKENDUPDATE CLOUDURL + "/update"
|
||||
|
||||
QNetworkReply* CloudStorageAuthenticate::backend(QString email, QString password, QString pin, QString newpasswd)
|
||||
QNetworkReply* CloudStorageAuthenticate::backend(const QString& email,const QString& password,const QString& pin,const QString& newpasswd)
|
||||
{
|
||||
QString payload(email + " " + password);
|
||||
QString payload(email + QChar(' ') + password);
|
||||
QUrl requestUrl;
|
||||
if (pin == "" && newpasswd == "") {
|
||||
if (pin.isEmpty() && newpasswd.isEmpty()) {
|
||||
requestUrl = QUrl(CLOUDBACKENDSTORAGE);
|
||||
} else if (newpasswd != "") {
|
||||
} else if (!newpasswd.isEmpty()) {
|
||||
requestUrl = QUrl(CLOUDBACKENDUPDATE);
|
||||
payload += " " + newpasswd;
|
||||
payload += QChar(' ') + newpasswd;
|
||||
} else {
|
||||
requestUrl = QUrl(CLOUDBACKENDVERIFY);
|
||||
payload += " " + pin;
|
||||
payload += QChar(' ') + pin;
|
||||
}
|
||||
QNetworkRequest *request = new QNetworkRequest(requestUrl);
|
||||
request->setRawHeader("Accept", "text/xml, text/plain");
|
||||
|
@ -48,7 +48,7 @@ void CloudStorageAuthenticate::uploadFinished()
|
|||
|
||||
QString cloudAuthReply(reply->readAll());
|
||||
qDebug() << "Completed connection with cloud storage backend, response" << cloudAuthReply;
|
||||
if (cloudAuthReply == "[VERIFIED]" || cloudAuthReply == "[OK]") {
|
||||
if (cloudAuthReply == QLatin1String("[VERIFIED]") || cloudAuthReply == QLatin1String("[OK]")) {
|
||||
prefs.cloud_verification_status = CS_VERIFIED;
|
||||
/* TODO: Move this to a correct place
|
||||
NotificationWidget *nw = MainWindow::instance()->getNotificationWidget();
|
||||
|
@ -56,9 +56,9 @@ void CloudStorageAuthenticate::uploadFinished()
|
|||
nw->hideNotification();
|
||||
*/
|
||||
myLastError.clear();
|
||||
} else if (cloudAuthReply == "[VERIFY]") {
|
||||
} else if (cloudAuthReply == QLatin1String("[VERIFY]")) {
|
||||
prefs.cloud_verification_status = CS_NEED_TO_VERIFY;
|
||||
} else if (cloudAuthReply == "[PASSWDCHANGED]") {
|
||||
} else if (cloudAuthReply == QLatin1String("[PASSWDCHANGED]")) {
|
||||
free(prefs.cloud_storage_password);
|
||||
prefs.cloud_storage_password = prefs.cloud_storage_newpassword;
|
||||
prefs.cloud_storage_newpassword = NULL;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
class CloudStorageAuthenticate : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QNetworkReply* backend(QString email, QString password, QString pin = "", QString newpasswd = "");
|
||||
QNetworkReply* backend(const QString& email,const QString& password,const QString& pin = QString(),const QString& newpasswd = QString());
|
||||
explicit CloudStorageAuthenticate(QObject *parent);
|
||||
signals:
|
||||
void finishedAuthenticate();
|
||||
|
|
Loading…
Add table
Reference in a new issue