mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +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 CLOUDBACKENDVERIFY CLOUDURL + "/verify"
|
||||||
#define CLOUDBACKENDUPDATE CLOUDURL + "/update"
|
#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;
|
QUrl requestUrl;
|
||||||
if (pin == "" && newpasswd == "") {
|
if (pin.isEmpty() && newpasswd.isEmpty()) {
|
||||||
requestUrl = QUrl(CLOUDBACKENDSTORAGE);
|
requestUrl = QUrl(CLOUDBACKENDSTORAGE);
|
||||||
} else if (newpasswd != "") {
|
} else if (!newpasswd.isEmpty()) {
|
||||||
requestUrl = QUrl(CLOUDBACKENDUPDATE);
|
requestUrl = QUrl(CLOUDBACKENDUPDATE);
|
||||||
payload += " " + newpasswd;
|
payload += QChar(' ') + newpasswd;
|
||||||
} else {
|
} else {
|
||||||
requestUrl = QUrl(CLOUDBACKENDVERIFY);
|
requestUrl = QUrl(CLOUDBACKENDVERIFY);
|
||||||
payload += " " + pin;
|
payload += QChar(' ') + pin;
|
||||||
}
|
}
|
||||||
QNetworkRequest *request = new QNetworkRequest(requestUrl);
|
QNetworkRequest *request = new QNetworkRequest(requestUrl);
|
||||||
request->setRawHeader("Accept", "text/xml, text/plain");
|
request->setRawHeader("Accept", "text/xml, text/plain");
|
||||||
|
@ -48,7 +48,7 @@ void CloudStorageAuthenticate::uploadFinished()
|
||||||
|
|
||||||
QString cloudAuthReply(reply->readAll());
|
QString cloudAuthReply(reply->readAll());
|
||||||
qDebug() << "Completed connection with cloud storage backend, response" << cloudAuthReply;
|
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;
|
prefs.cloud_verification_status = CS_VERIFIED;
|
||||||
/* TODO: Move this to a correct place
|
/* TODO: Move this to a correct place
|
||||||
NotificationWidget *nw = MainWindow::instance()->getNotificationWidget();
|
NotificationWidget *nw = MainWindow::instance()->getNotificationWidget();
|
||||||
|
@ -56,9 +56,9 @@ void CloudStorageAuthenticate::uploadFinished()
|
||||||
nw->hideNotification();
|
nw->hideNotification();
|
||||||
*/
|
*/
|
||||||
myLastError.clear();
|
myLastError.clear();
|
||||||
} else if (cloudAuthReply == "[VERIFY]") {
|
} else if (cloudAuthReply == QLatin1String("[VERIFY]")) {
|
||||||
prefs.cloud_verification_status = CS_NEED_TO_VERIFY;
|
prefs.cloud_verification_status = CS_NEED_TO_VERIFY;
|
||||||
} else if (cloudAuthReply == "[PASSWDCHANGED]") {
|
} else if (cloudAuthReply == QLatin1String("[PASSWDCHANGED]")) {
|
||||||
free(prefs.cloud_storage_password);
|
free(prefs.cloud_storage_password);
|
||||||
prefs.cloud_storage_password = prefs.cloud_storage_newpassword;
|
prefs.cloud_storage_password = prefs.cloud_storage_newpassword;
|
||||||
prefs.cloud_storage_newpassword = NULL;
|
prefs.cloud_storage_newpassword = NULL;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
class CloudStorageAuthenticate : public QObject {
|
class CloudStorageAuthenticate : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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);
|
explicit CloudStorageAuthenticate(QObject *parent);
|
||||||
signals:
|
signals:
|
||||||
void finishedAuthenticate();
|
void finishedAuthenticate();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue