From kde-commits Thu Oct 15 21:01:20 2015 From: Alex Fiestas Date: Thu, 15 Oct 2015 21:01:20 +0000 To: kde-commits Subject: [kaccounts-providers] /: Check if the credentials are ok, then go to the service page. Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=144494289424983 Git commit 4516e78847b89ede27edda3bcdfb418c0aef88c4 by Alex Fiestas. Committed on 17/04/2012 at 16:26. Pushed by mklapetek into branch 'master'. Check if the credentials are ok, then go to the service page. The credentials are not beautiful handled but it works, will polish later M +37 -0 connecting.cpp M +6 -0 connecting.h M +7 -0 connecting.ui http://commits.kde.org/kaccounts-providers/4516e78847b89ede27edda3bcdfb418c= 0aef88c4 diff --git a/connecting.cpp b/connecting.cpp index e98b065..e89d94c 100644 --- a/connecting.cpp +++ b/connecting.cpp @@ -18,7 +18,11 @@ = #include "connecting.h" #include "owncloud.h" + +#include + #include +#include = Connecting::Connecting(OwnCloudWizard* parent) : QWizardPage(parent) @@ -38,4 +42,37 @@ Connecting::~Connecting() void Connecting::initializePage() { server->setText(m_wizard->server().host()); + + QMetaObject::invokeMethod(this, "checkAuth", Qt::QueuedConnection); } + +void Connecting::checkAuth() +{ + KUrl url(m_wizard->server()); + + url.setUser(m_wizard->username()); + url.setPass(m_wizard->password()); + + url.addPath("apps/calendar/caldav.php/"); + qDebug() << "FinalUrL: " << url; + KIO::TransferJob *job =3D KIO::get(url, KIO::NoReload, KIO::HideProgre= ssInfo); + connect(job, SIGNAL(finished(KJob*)), this, SLOT(httpResult(KJob*))); + + job->setUiDelegate(0); +} + +void Connecting::httpResult(KJob* job) +{ + if (job->error()) { + qDebug() << job->errorString(); + qDebug() << job->errorText(); + } + + KIO::TransferJob *kJob =3D qobject_cast(job); + if (kJob->isErrorPage()) { + error->setText(i18n("User or password are incorrect")); + return; + } + + m_wizard->next(); +} \ No newline at end of file diff --git a/connecting.h b/connecting.h index ce94586..5a8aaa5 100644 --- a/connecting.h +++ b/connecting.h @@ -24,6 +24,7 @@ #include #include = +class KJob; class OwnCloudWizard; class Connecting : public QWizardPage, Ui::Connecting { @@ -33,6 +34,11 @@ class Connecting : public QWizardPage, Ui::Connecting virtual ~Connecting(); = virtual void initializePage(); + + private Q_SLOTS: + void checkAuth(); + void httpResult(KJob *job); + private: OwnCloudWizard *m_wizard; }; diff --git a/connecting.ui b/connecting.ui index a480422..ade98bc 100644 --- a/connecting.ui +++ b/connecting.ui @@ -74,6 +74,13 @@ + + + + + + + Qt::Vertical