Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b968a16a authored by Laurent Montel's avatar Laurent Montel 😁

Const'ify

parent 8e36fc8a
......@@ -48,20 +48,20 @@ void O0BaseAuth::setLinked(bool v)
QString O0BaseAuth::tokenSecret()
{
QString key = QString::fromLatin1(O2_KEY_TOKEN_SECRET).arg(clientId_);
const QString key = QString::fromLatin1(O2_KEY_TOKEN_SECRET).arg(clientId_);
return store_->value(key);
}
void O0BaseAuth::setTokenSecret(const QString &v)
{
QString key = QString::fromLatin1(O2_KEY_TOKEN_SECRET).arg(clientId_);
const QString key = QString::fromLatin1(O2_KEY_TOKEN_SECRET).arg(clientId_);
store_->setValue(key, v);
Q_EMIT tokenSecretChanged();
}
QString O0BaseAuth::token()
QString O0BaseAuth::token() const
{
QString key = QString::fromLatin1(O2_KEY_TOKEN).arg(clientId_);
const QString key = QString::fromLatin1(O2_KEY_TOKEN).arg(clientId_);
return store_->value(key);
}
......@@ -72,7 +72,7 @@ void O0BaseAuth::setToken(const QString &v)
Q_EMIT tokenChanged();
}
QString O0BaseAuth::clientId()
QString O0BaseAuth::clientId() const
{
return clientId_;
}
......@@ -83,7 +83,7 @@ void O0BaseAuth::setClientId(const QString &value)
Q_EMIT clientIdChanged();
}
QString O0BaseAuth::clientSecret()
QString O0BaseAuth::clientSecret() const
{
return clientSecret_;
}
......@@ -94,7 +94,7 @@ void O0BaseAuth::setClientSecret(const QString &value)
Q_EMIT clientSecretChanged();
}
int O0BaseAuth::localPort()
int O0BaseAuth::localPort() const
{
return localPort_;
}
......
......@@ -25,7 +25,7 @@ public:
/// Authentication token.
Q_PROPERTY(QString token READ token NOTIFY tokenChanged)
QString token();
QString token() const;
/// Authentication token secret.
Q_PROPERTY(QString tokenSecret READ tokenSecret NOTIFY tokenSecretChanged)
......@@ -38,20 +38,20 @@ public:
/// Client application ID.
/// O1 instances with the same (client ID, client secret) share the same "linked", "token" and "tokenSecret" properties.
Q_PROPERTY(QString clientId READ clientId WRITE setClientId NOTIFY clientIdChanged)
QString clientId();
QString clientId() const;
void setClientId(const QString &value);
/// Client application secret.
/// O1 instances with the same (client ID, client secret) share the same "linked", "token" and "tokenSecret" properties.
Q_PROPERTY(QString clientSecret READ clientSecret WRITE setClientSecret NOTIFY clientSecretChanged)
QString clientSecret();
QString clientSecret() const;
void setClientSecret(const QString &value);
/// TCP port number to use in local redirections.
/// The OAuth "redirect_uri" will be set to "http://localhost:<localPort>/".
/// If localPort is set to 0 (default), O2 will replace it with a free one.
Q_PROPERTY(int localPort READ localPort WRITE setLocalPort NOTIFY localPortChanged)
int localPort();
int localPort() const;
void setLocalPort(int value);
/// Sets the storage object to use for storing the OAuth tokens on a peristent medium
......
......@@ -87,7 +87,7 @@ void O2::setGrantFlow(O2::GrantFlow value)
Q_EMIT grantFlowChanged();
}
QString O2::username()
QString O2::username() const
{
return username_;
}
......@@ -333,19 +333,19 @@ QByteArray O2::buildRequestBody(const QMap<QString, QString> &parameters)
int O2::expires()
{
QString key = QString(O2_KEY_EXPIRES).arg(clientId_);
const QString key = QString(O2_KEY_EXPIRES).arg(clientId_);
return store_->value(key).toInt();
}
void O2::setExpires(int v)
{
QString key = QString(O2_KEY_EXPIRES).arg(clientId_);
const QString key = QString(O2_KEY_EXPIRES).arg(clientId_);
store_->setValue(key, QString::number(v));
}
QString O2::refreshToken()
{
QString key = QString(O2_KEY_REFRESH_TOKEN).arg(clientId_);
const QString key = QString(O2_KEY_REFRESH_TOKEN).arg(clientId_);
return store_->value(key);
}
......
......@@ -32,7 +32,7 @@ public:
/// Resource owner username.
/// O2 instances with the same (username, password) share the same "linked" and "token" properties.
Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged)
QString username();
QString username() const;
void setUsername(const QString &value);
/// Resource owner password.
......
......@@ -15,7 +15,7 @@
O2ReplyServer::O2ReplyServer(QObject *parent): QTcpServer(parent)
{
connect(this, &QTcpServer::newConnection, this, &O2ReplyServer::onIncomingConnection);
replyContent_ = "<HTML></HTML>";
replyContent_ = QByteArrayLiteral("<HTML></HTML>");
}
void O2ReplyServer::onIncomingConnection()
......
......@@ -151,25 +151,25 @@ QString O0SimpleCrypt::encryptToString(const QByteArray &plaintext)
QString O0SimpleCrypt::decryptToString(const QString &cyphertext)
{
QByteArray cyphertextArray = QByteArray::fromBase64(cyphertext.toLatin1());
QByteArray plaintextArray = decryptToByteArray(cyphertextArray);
QString plaintext = QString::fromUtf8(plaintextArray.constData(), plaintextArray.size());
const QByteArray cyphertextArray = QByteArray::fromBase64(cyphertext.toLatin1());
const QByteArray plaintextArray = decryptToByteArray(cyphertextArray);
const QString plaintext = QString::fromUtf8(plaintextArray.constData(), plaintextArray.size());
return plaintext;
}
QString O0SimpleCrypt::decryptToString(const QByteArray &cypher)
{
QByteArray ba = decryptToByteArray(cypher);
QString plaintext = QString::fromUtf8(ba.constData(), ba.size());
const QByteArray ba = decryptToByteArray(cypher);
const QString plaintext = QString::fromUtf8(ba.constData(), ba.size());
return plaintext;
}
QByteArray O0SimpleCrypt::decryptToByteArray(const QString &cyphertext)
{
QByteArray cyphertextArray = QByteArray::fromBase64(cyphertext.toLatin1());
QByteArray ba = decryptToByteArray(cyphertextArray);
const QByteArray cyphertextArray = QByteArray::fromBase64(cyphertext.toLatin1());
const QByteArray ba = decryptToByteArray(cyphertextArray);
return ba;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment