summaryrefslogtreecommitdiffstats
path: root/subsurface-core
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2016-01-26 12:28:38 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-26 09:51:14 -0800
commitccf29679ae6e9eebf63a925dc99021c8f1e402dc (patch)
treeb3fe1510f355a2b7e272928882d676f476d43b5b /subsurface-core
parent8b7427c56d487a9f41afef01b6d7952e8e1e15af (diff)
downloadsubsurface-ccf29679ae6e9eebf63a925dc99021c8f1e402dc.tar.gz
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>
Diffstat (limited to 'subsurface-core')
-rw-r--r--subsurface-core/cloudstorage.cpp18
-rw-r--r--subsurface-core/cloudstorage.h2
2 files changed, 10 insertions, 10 deletions
diff --git a/subsurface-core/cloudstorage.cpp b/subsurface-core/cloudstorage.cpp
index 25a2f56f2..4f58d0191 100644
--- a/subsurface-core/cloudstorage.cpp
+++ b/subsurface-core/cloudstorage.cpp
@@ -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;
diff --git a/subsurface-core/cloudstorage.h b/subsurface-core/cloudstorage.h
index b4b21dd2a..6addb739d 100644
--- a/subsurface-core/cloudstorage.h
+++ b/subsurface-core/cloudstorage.h
@@ -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();