Show webfinger if displayName is unknown for an author.
[larjonas-pumpa.git] / src / oauthwizard.h
blobeeebcd02c051988ed5424c96438ed0a01b0d86f3
1 /*
2 Copyright 2013-2015 Mats Sjöberg
4 This file is part of the Pumpa programme.
6 Pumpa is free software: you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 Pumpa is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Pumpa. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _OAUTHWIZARD_H_
21 #define _OAUTHWIZARD_H_
23 #include <QWidget>
24 #include <QLabel>
25 #include <QWizard>
26 #include <QWizardPage>
27 #include <QNetworkAccessManager>
29 #include "QtKOAuth"
31 //------------------------------------------------------------------------------
33 class OAuthFirstPage : public QWizardPage {
34 Q_OBJECT
36 public:
37 OAuthFirstPage(QWidget* parent=0);
38 void setMessage(QString msg);
40 signals:
41 void committed(QString, QString);
43 protected:
44 virtual bool validatePage();
45 virtual bool isComplete() const;
47 private:
48 bool splitAccountId(QString& username, QString& server) const;
49 QLabel* m_messageLabel;
52 //------------------------------------------------------------------------------
54 class OAuthSecondPage : public QWizardPage {
55 Q_OBJECT
57 public:
58 OAuthSecondPage(QWidget* parent=0);
60 protected:
61 virtual bool validatePage();
63 signals:
64 void committed(QString, QString);
67 //------------------------------------------------------------------------------
69 class OAuthWizard : public QWizard {
70 Q_OBJECT
72 public:
73 OAuthWizard(QNetworkAccessManager* nam, KQOAuthManager* oam,
74 QWidget* parent=0);
76 signals:
77 void clientRegistered(QString, QString, QString, QString);
78 void accessTokenReceived(QString, QString);
80 private slots:
81 void onFirstPageCommitted(QString, QString);
82 void onSecondPageCommitted(QString, QString);
84 void onOAuthClientRegDone();
85 void onTemporaryTokenReceived(QString temporaryToken,
86 QString temporaryTokenSecret);
87 void onAccessTokenReceived(QString token, QString tokenSecret);
89 private:
90 void notifyMessage(QString);
91 void errorMessage(QString);
93 void registerOAuthClient();
94 void getOAuthAccess();
96 OAuthFirstPage* p1;
97 OAuthSecondPage* p2;
99 KQOAuthManager *m_oam;
100 KQOAuthRequest *m_oar;
101 QNetworkAccessManager *m_nam;
103 QString m_server, m_username;
104 QString m_clientId, m_clientSecret;
106 int m_clientRegTryCount;
109 #endif /* _OAUTHWIZARD_H_ */