[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kaccounts-providers] /: Check if the credentials are ok, then go to the service page.
From:       Alex Fiestas <afiestas () kde ! org>
Date:       2015-10-15 21:01:20
Message-ID: E1ZmpeK-0000yK-LL () scm ! kde ! org
[Download RAW message or body]

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/4516e78847b89ede27edda3bcdfb418c0aef88c4

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 <QtCore/QDebug>
+
 #include <KPixmapSequenceOverlayPainter>
+#include <KIO/Job>
 
 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 = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
+    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 = qobject_cast<KIO::TransferJob*>(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 <QtGui/QWizardPage>
 #include <KJob>
 
+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 @@
     </layout>
    </item>
    <item>
+    <widget class="QLabel" name="error">
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item>
     <spacer name="verticalSpacer">
      <property name="orientation">
       <enum>Qt::Vertical</enum>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic