File indexing completed on 2024-04-28 05:26:49
0001 /******************************************************************* 0002 * bugzillalib.h 0003 * SPDX-FileCopyrightText: 2009, 2011 Dario Andres Rodriguez <andresbajotierra@gmail.com> 0004 * SPDX-FileCopyrightText: 2012 George Kiagiadakis <kiagiadakis.george@gmail.com> 0005 * SPDX-FileCopyrightText: 2019-2022 Harald Sitter <sitter@kde.org> 0006 * 0007 * SPDX-License-Identifier: GPL-2.0-or-later 0008 * 0009 ******************************************************************/ 0010 0011 #ifndef BUGZILLALIB__H 0012 #define BUGZILLALIB__H 0013 0014 #include <QObject> 0015 #include <QString> 0016 0017 #include "libbugzilla/clients/commands/newbug.h" 0018 #include "libbugzilla/models/product.h" 0019 0020 namespace KIO 0021 { 0022 class KJob; 0023 } 0024 0025 class BugzillaManager : public QObject 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 // Note: it expect the bugTrackerUrl parameter to contain the trailing slash. 0031 // so it should be "https://bugs.kde.org/", not "https://bugs.kde.org" 0032 explicit BugzillaManager(const QString &bugTrackerUrl = QString(), QObject *parent = nullptr); 0033 0034 /* Login methods */ 0035 Q_SCRIPTABLE void tryLogin(const QString &username, const QString &password); 0036 Q_INVOKABLE void refreshToken(); 0037 bool getLogged() const; 0038 0039 QString getUsername() const; 0040 0041 /* Bugzilla Action methods */ 0042 void sendReport(const Bugzilla::NewBug &bug); 0043 void attachTextToReport(const QString &text, const QString &filename, const QString &description, int bugId, const QString &comment); 0044 void fetchProductInfo(const QString &); 0045 0046 /* Misc methods */ 0047 QString urlForBug(int bug_number) const; 0048 Q_SCRIPTABLE void lookupVersion(); 0049 0050 Q_SIGNALS: 0051 /* Bugzilla actions finished successfully */ 0052 void loginFinished(bool logged); 0053 void reportSent(int bugId); 0054 void attachToReportSent(int bugId); 0055 void productInfoFetched(const Bugzilla::Product::Ptr &product); 0056 void bugzillaVersionFound(); 0057 0058 /* Bugzilla actions had errors */ 0059 void loginError(const QString &errorMsg); 0060 void bugReportError(const QString &errorMsg, QObject *jobOwner); 0061 void sendReportError(const QString &errorMsg); 0062 void sendReportErrorInvalidValues(); // To use default values 0063 void attachToReportError(const QString &errorMsg); 0064 void productInfoError(); 0065 void bugzillaVersionError(const QString &errorMsg); 0066 0067 private: 0068 QString m_bugTrackerUrl; 0069 QString m_username; 0070 QString m_token; 0071 QString m_password; 0072 bool m_logged = false; 0073 0074 void setFeaturesForVersion(const QString &version); 0075 }; 0076 0077 #endif