Commit 0c203fdf authored by Dan Leinir Turthra Jensen's avatar Dan Leinir Turthra Jensen 🌈
Browse files

Also rename the job code itself

parent ff77839b
......@@ -16,13 +16,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include "accountservicetoggle.h"
#include "accountservicetogglejob.h"
#include <QDebug>
#include "core.h"
#include <Accounts/Manager>
class AccountServiceToggle::Private {
class AccountServiceToggleJob::Private {
public:
Private() {}
QString accountId;
......@@ -30,50 +30,50 @@ public:
bool serviceEnabled{false};
};
AccountServiceToggle::AccountServiceToggle(QObject* parent)
AccountServiceToggleJob::AccountServiceToggleJob(QObject* parent)
: KJob(parent)
, d(new Private)
{ }
AccountServiceToggle::~AccountServiceToggle()
AccountServiceToggleJob::~AccountServiceToggleJob()
{
delete d;
}
QString AccountServiceToggle::accountId() const
QString AccountServiceToggleJob::accountId() const
{
return d->accountId;
}
void AccountServiceToggle::setAccountId(const QString& accountId)
void AccountServiceToggleJob::setAccountId(const QString& accountId)
{
d->accountId = accountId;
Q_EMIT accountIdChanged();
}
QString AccountServiceToggle::serviceId() const
QString AccountServiceToggleJob::serviceId() const
{
return d->serviceId;
}
void AccountServiceToggle::setServiceId(const QString& serviceId)
void AccountServiceToggleJob::setServiceId(const QString& serviceId)
{
d->serviceId = serviceId;
Q_EMIT serviceIdChanged();
}
bool AccountServiceToggle::serviceEnabled() const
bool AccountServiceToggleJob::serviceEnabled() const
{
return d->serviceEnabled;
}
void AccountServiceToggle::setServiceEnabled(bool serviceEnabled)
void AccountServiceToggleJob::setServiceEnabled(bool serviceEnabled)
{
d->serviceEnabled = serviceEnabled;
Q_EMIT serviceEnabledChanged();
}
void AccountServiceToggle::start()
void AccountServiceToggleJob::start()
{
Accounts::Manager* accountsManager = KAccounts::accountsManager();
if (accountsManager) {
......
......@@ -20,19 +20,21 @@
#define ACCOUNTSERVICETOGGLE_H
#include "kaccounts_export.h"
#include <kjob.h>
#include <QStringList>
class AccountServiceToggle : public KJob
class KACCOUNTS_EXPORT AccountServiceToggleJob : public KJob
{
Q_OBJECT
Q_PROPERTY(QString accountId READ accountId WRITE setAccountId NOTIFY accountIdChanged)
Q_PROPERTY(QString serviceId READ serviceId WRITE setServiceId NOTIFY serviceIdChanged)
Q_PROPERTY(bool serviceEnabled READ serviceEnabled WRITE setServiceEnabled NOTIFY serviceEnabledChanged)
public:
explicit AccountServiceToggle(QObject* parent = nullptr);
virtual ~AccountServiceToggle();
explicit AccountServiceToggleJob(QObject* parent = nullptr);
virtual ~AccountServiceToggleJob();
void start() override;
......
......@@ -16,9 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include "createaccount.h"
#include "lib/kaccountsuiplugin.h"
#include "lib/core.h"
#include "createaccountjob.h"
#include "kaccountsuiplugin.h"
#include "core.h"
#include "uipluginsmanager.h"
#include <QDebug>
......@@ -33,13 +34,13 @@
#include <KLocalizedString>
CreateAccount::CreateAccount(QObject* parent)
: CreateAccount(QString(), parent)
CreateAccountJob::CreateAccountJob(QObject* parent)
: CreateAccountJob(QString(), parent)
{
}
CreateAccount::CreateAccount(const QString &providerName, QObject* parent)
CreateAccountJob::CreateAccountJob(const QString &providerName, QObject* parent)
: KJob(parent)
, m_providerName(providerName)
, m_manager(new Accounts::Manager(this))
......@@ -51,13 +52,13 @@ CreateAccount::CreateAccount(const QString &providerName, QObject* parent)
}
void CreateAccount::start()
void CreateAccountJob::start()
{
qDebug() << m_providerName;
QMetaObject::invokeMethod(this, "processSession");
}
void CreateAccount::processSession()
void CreateAccountJob::processSession()
{
m_account = m_manager->createAccount(m_providerName);
Accounts::Service service;
......@@ -80,7 +81,7 @@ void CreateAccount::processSession()
m_identity = SignOn::Identity::newIdentity(info, this);
m_identity->storeCredentials();
connect(m_identity, &SignOn::Identity::info, this, &CreateAccount::info);
connect(m_identity, &SignOn::Identity::info, this, &CreateAccountJob::info);
connect(m_identity, &SignOn::Identity::error, [=](const SignOn::Error &err) {
qDebug() << "Error storing identity:" << err.message();
});
......@@ -91,14 +92,14 @@ void CreateAccount::processSession()
SignOn::SessionData sessionData(data);
SignOn::AuthSessionP session = m_identity->createSession(m_accInfo->authData().method());
qDebug() << "Starting auth session with" << m_accInfo->authData().method();
connect(session, &SignOn::AuthSession::error, this, &CreateAccount::sessionError);
connect(session, &SignOn::AuthSession::response, this, &CreateAccount::sessionResponse);
connect(session, &SignOn::AuthSession::error, this, &CreateAccountJob::sessionError);
connect(session, &SignOn::AuthSession::response, this, &CreateAccountJob::sessionResponse);
session->process(sessionData, m_accInfo->authData().mechanism());
}
}
void CreateAccount::loadPluginAndShowDialog(const QString &pluginName)
void CreateAccountJob::loadPluginAndShowDialog(const QString &pluginName)
{
KAccountsUiPlugin *ui = KAccounts::UiPluginsManager::pluginForName(pluginName);
......@@ -108,14 +109,14 @@ void CreateAccount::loadPluginAndShowDialog(const QString &pluginName)
return;
}
connect(ui, &KAccountsUiPlugin::success, this, &CreateAccount::pluginFinished, Qt::UniqueConnection);
connect(ui, &KAccountsUiPlugin::error, this, &CreateAccount::pluginError, Qt::UniqueConnection);
connect(ui, &KAccountsUiPlugin::success, this, &CreateAccountJob::pluginFinished, Qt::UniqueConnection);
connect(ui, &KAccountsUiPlugin::error, this, &CreateAccountJob::pluginError, Qt::UniqueConnection);
ui->setProviderName(m_providerName);
ui->init(KAccountsUiPlugin::NewAccountDialog);
}
void CreateAccount::pluginFinished(const QString &screenName, const QString &secret, const QVariantMap &data)
void CreateAccountJob::pluginFinished(const QString &screenName, const QString &secret, const QVariantMap &data)
{
// Set up the new identity
SignOn::IdentityInfo info;
......@@ -138,7 +139,7 @@ void CreateAccount::pluginFinished(const QString &screenName, const QString &sec
}
m_identity = SignOn::Identity::newIdentity(info, this);
connect(m_identity, &SignOn::Identity::info, this, &CreateAccount::info);
connect(m_identity, &SignOn::Identity::info, this, &CreateAccountJob::info);
m_done = true;
......@@ -146,7 +147,7 @@ void CreateAccount::pluginFinished(const QString &screenName, const QString &sec
m_identity->storeCredentials();
}
void CreateAccount::pluginError(const QString &error)
void CreateAccountJob::pluginError(const QString &error)
{
if (error.isEmpty()) {
setError(-1);
......@@ -158,7 +159,7 @@ void CreateAccount::pluginError(const QString &error)
emitResult();
}
void CreateAccount::sessionResponse(const SignOn::SessionData &/*data*/)
void CreateAccountJob::sessionResponse(const SignOn::SessionData &/*data*/)
{
qDebug() << "Received session response";
......@@ -166,7 +167,7 @@ void CreateAccount::sessionResponse(const SignOn::SessionData &/*data*/)
m_identity->queryInfo();
}
void CreateAccount::info(const SignOn::IdentityInfo &info)
void CreateAccountJob::info(const SignOn::IdentityInfo &info)
{
qDebug() << "Info:";
qDebug() << "\tId:" << info.id();
......@@ -213,10 +214,10 @@ void CreateAccount::info(const SignOn::IdentityInfo &info)
m_account->selectService();
m_account->setEnabled(true);
m_account->sync();
connect(m_account, &Accounts::Account::synced, this, &CreateAccount::emitResult);
connect(m_account, &Accounts::Account::synced, this, &CreateAccountJob::emitResult);
}
void CreateAccount::sessionError(const SignOn::Error &signOnError)
void CreateAccountJob::sessionError(const SignOn::Error &signOnError)
{
if (error()) {
// Guard against SignOn sending two error() signals
......@@ -230,7 +231,7 @@ void CreateAccount::sessionError(const SignOn::Error &signOnError)
emitResult();
}
void CreateAccount::setProviderName(const QString &name)
void CreateAccountJob::setProviderName(const QString &name)
{
if (m_providerName != name) {
m_providerName = name;
......
......@@ -19,6 +19,8 @@
#ifndef CREATE_ACCOUNT_JOB_H
#define CREATE_ACCOUNT_JOB_H
#include "kaccounts_export.h"
#include <kjob.h>
#include <QStringList>
......@@ -37,13 +39,13 @@ namespace SignOn
class IdentityInfo;
}
class CreateAccount : public KJob
class KACCOUNTS_EXPORT CreateAccountJob : public KJob
{
Q_OBJECT
Q_PROPERTY(QString providerName READ providerName WRITE setProviderName NOTIFY providerNameChanged)
public:
explicit CreateAccount(QObject* parent = nullptr);
explicit CreateAccount(const QString &providerName, QObject* parent = nullptr);
explicit CreateAccountJob(QObject* parent = nullptr);
explicit CreateAccountJob(const QString &providerName, QObject* parent = nullptr);
QString providerName() const { return m_providerName; }
void setProviderName(const QString &name);
......
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