File indexing completed on 2024-05-05 04:39:54
0001 /* 0002 SPDX-FileCopyrightText: 2012-2013 Miquel Sabaté <mikisabate@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef GH_DIALOG_H 0008 #define GH_DIALOG_H 0009 0010 0011 #include <QDialog> 0012 0013 class QLabel; 0014 0015 namespace gh 0016 { 0017 class Account; 0018 0019 /** 0020 * @class Dialog 0021 * 0022 * The Dialog class handles the configuration dialog to be shown so the 0023 * user can setup its Github account. 0024 */ 0025 class Dialog : public QDialog 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 /** 0031 * Constructor. 0032 * 0033 * @param parent The QWidget this Dialog is parented to. 0034 * @param account The user's account. 0035 */ 0036 explicit Dialog(QWidget *parent, Account *account); 0037 0038 Q_SIGNALS: 0039 /** 0040 * This signal is emitted whenever the dialog has successfully performed 0041 * an action that may imply some changes on the UI of the plugin. 0042 */ 0043 void shouldUpdate(); 0044 0045 private Q_SLOTS: 0046 /** 0047 * The "Authorize" button has been clicked. a KPasswordDialog will be 0048 * shown and a request will be sent to Github to authenticate the given 0049 * user. 0050 */ 0051 void authorizeClicked(); 0052 0053 /** 0054 * Handle a response from Github on the authorization process. If the 0055 * given id is empty, it means that something went wrong. Otherwise, when 0056 * successful, it will also call the syncUser method. 0057 * 0058 * @param id The id of the authorization. 0059 * @param token The authorization token. 0060 */ 0061 void authorizeResponse(const QByteArray &id, const QByteArray &token, const QString &tokenName); 0062 0063 /** 0064 * Handle a two factor response from GitHub during the authorization process. 0065 */ 0066 void twoFactorResponse(const QString &transferHeader); 0067 0068 /// Sync the user's groups. 0069 void syncUser(); 0070 0071 /** 0072 * Update the organization list of the current user. 0073 * 0074 * @param orgs A list of organizations for the current user. 0075 */ 0076 void updateOrgs(const QStringList& orgs); 0077 0078 /// Revoke the access of this application. 0079 void revokeAccess(); 0080 0081 private: 0082 Account *m_account; 0083 QString m_name; 0084 QLabel *m_text; 0085 }; 0086 0087 } // End of namespace gh 0088 0089 0090 #endif /* GH_DIALOG_H */