mirror of
https://github.com/arcan1s/reportabug.git
synced 2025-04-24 15:27:18 +00:00
release 1.0.1
* fix captcha
This commit is contained in:
parent
33f6282224
commit
33fdd14e79
@ -50,13 +50,11 @@ This module requires `QtNetwork` module. To enable this module set up your token
|
||||
|
||||
Available variables:
|
||||
|
||||
* `CAPTCHA_KEY` - captcha key. It may be found in the source of the `PUBLIC_URL` page. Default is `7f6ef90bce7389088a52c5c9101aad206b21b56d`.
|
||||
* `CAPTCHA_TEXT` - captcha text. It may be found in the source of the `PUBLIC_URL` page. Default is `QJNZXY`.
|
||||
* `CAPTCHA_TIME` - captcha time. It may be found in the source of the `PUBLIC_URL` page. Default is `1406531273`.
|
||||
* `CAPTCHA_URL` - captcha url, in the most cases do not touch it. Default is `https://gitreports.com/simple_captcha?code=`.
|
||||
* `GITREPORT_COMBOBOX` - text of this module into comboBox.
|
||||
* `PUBLIC_URL` - issues url, in the most cases do not touch it. Default is `https://gitreports.com/issue/$OWNER/$PROJECT`. Available tags here are `$PROJECT`, `$OWNER`.
|
||||
|
||||
This module requires `QtWebKit` module. To disable this module use `-DENABLE_GITREPORT=0` cmake flag.
|
||||
This module requires `QtWebKit` and `QtNetwork` modules. To disable this module use `-DENABLE_GITREPORT=0` cmake flag.
|
||||
|
||||
Instruction
|
||||
===========
|
||||
@ -65,10 +63,10 @@ Dependencies
|
||||
------------
|
||||
|
||||
* qt5-base (if Qt5 is used) or qt4 (if Qt4 is used)
|
||||
* qt5-network (if Qt5 is used)
|
||||
|
||||
### Optional dependencies ###
|
||||
|
||||
* qt5-network (if Qt5 is used) *(requires for GitHub module)*
|
||||
* qt5-webkit (if Qt5 is used) or qtwebkit (if Qt4 is used) *(requires for GitReport module)*
|
||||
* doxygen *(developers documentation)*
|
||||
|
||||
|
@ -13,7 +13,7 @@ set (SUBPROJECT_CONTACT "esalexeev@gmail.com")
|
||||
set (SUBPROJECT_LICENSE "LGPLv3")
|
||||
set (SUBPROJECT_VERSION_MAJOR 1)
|
||||
set (SUBPROJECT_VERSION_MINOR 0)
|
||||
set (SUBPROJECT_VERSION_PATCH 0)
|
||||
set (SUBPROJECT_VERSION_PATCH 1)
|
||||
set (SUBPROJECT_VERSION ${SUBPROJECT_VERSION_MAJOR}.${SUBPROJECT_VERSION_MINOR}.${SUBPROJECT_VERSION_PATCH})
|
||||
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
|
||||
string (TIMESTAMP CURRENT_YEAR "%Y")
|
||||
|
@ -22,16 +22,12 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
if (USE_QT5)
|
||||
find_package (Qt5Core REQUIRED)
|
||||
find_package (Qt5Widgets REQUIRED)
|
||||
find_package (Qt5Network REQUIRED)
|
||||
add_definitions (${Qt5Core_DEFINITIONS})
|
||||
add_definitions (${Qt5Widgets_DEFINITIONS})
|
||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||
set (QT_USED_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES})
|
||||
if (ENABLE_GITHUB OR USE_OWN_TOKEN)
|
||||
find_package (Qt5Network REQUIRED)
|
||||
add_definitions (${Qt5Network_DEFINITIONS})
|
||||
include_directories (${Qt5Network_INCLUDE_DIRS})
|
||||
set (QT_USED_LIBRARIES ${QT_USED_LIBRARIES} ${Qt5Network_LIBRARIES})
|
||||
endif ()
|
||||
add_definitions (${Qt5Network_DEFINITIONS})
|
||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
|
||||
set (QT_USED_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES})
|
||||
if (ENABLE_GITREPORT)
|
||||
find_package (Qt5WebKit REQUIRED)
|
||||
find_package (Qt5WebKitWidgets REQUIRED)
|
||||
@ -48,19 +44,13 @@ if (USE_QT5)
|
||||
source_group ("Generated Files" FILES ${MOC_SOURCES})
|
||||
|
||||
else ()
|
||||
set (QT_USED_COMPONENTS QtCore QtGui)
|
||||
if (ENABLE_GITHUB OR USE_OWN_TOKEN)
|
||||
set (QT_USED_COMPONENTS ${QT_USED_COMPONENTS} QtNetwork)
|
||||
endif ()
|
||||
set (QT_USED_COMPONENTS QtCore QtGui QtNetwork)
|
||||
if (ENABLE_GITREPORT)
|
||||
set (QT_USED_COMPONENTS ${QT_USED_COMPONENTS} QtWebKit)
|
||||
endif ()
|
||||
find_package(Qt4 COMPONENTS ${QT_USED_COMPONENTS} REQUIRED)
|
||||
include (${QT_USE_FILE})
|
||||
set (QT_USED_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
|
||||
if (ENABLE_GITHUB OR USE_OWN_TOKEN)
|
||||
set (QT_USED_LIBRARIES ${QT_USED_LIBRARIES} ${QT_QTNETWORK_LIBRARY})
|
||||
endif ()
|
||||
set (QT_USED_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY})
|
||||
if (ENABLE_GITREPORT)
|
||||
set (QT_USED_LIBRARIES ${QT_USED_LIBRARIES} ${QT_QTWEBKIT_LIBRARY})
|
||||
endif ()
|
||||
|
@ -69,10 +69,8 @@
|
||||
// public link; in the most cases do not touch it
|
||||
// available tags are $PROJECT, $OWNER
|
||||
#define PUBLIC_URL "https://gitreports.com/issue/$OWNER/$PROJECT"
|
||||
// captcha
|
||||
#define CAPTCHA_KEY "7f6ef90bce7389088a52c5c9101aad206b21b56d"
|
||||
#define CAPTCHA_TEXT "QJNZXY"
|
||||
#define CAPTCHA_TIME "1406531273"
|
||||
// captcha url; in the most cases do not touch it
|
||||
#define CAPTCHA_URL "https://gitreports.com/simple_captcha?code="
|
||||
|
||||
|
||||
#endif /* CONFIG_H */
|
||||
|
@ -159,7 +159,7 @@ void GithubModule::githubFinished(QNetworkReply *reply)
|
||||
if (debug) qDebug() << "[GithubModule]" << "[githubFinished]" << ":" << "Error state" << reply->error();
|
||||
if (debug) qDebug() << "[GithubModule]" << "[githubFinished]" << ":" << "Reply size" << reply->readBufferSize();
|
||||
|
||||
int state = true;
|
||||
bool state = true;
|
||||
QString answer = reply->readAll();
|
||||
if (debug) qDebug() << "[GithubModule]" << "[replyFinished]" << ":" << answer;
|
||||
QString messageBody, messageTitle;
|
||||
@ -189,6 +189,7 @@ void GithubModule::githubFinished(QNetworkReply *reply)
|
||||
icon = QMessageBox::Critical;
|
||||
state = false;
|
||||
}
|
||||
reply->deleteLater();
|
||||
|
||||
QMessageBox messageBox;
|
||||
messageBox.setText(messageTitle);
|
||||
|
@ -29,6 +29,9 @@
|
||||
#include <QDebug>
|
||||
#include <QGridLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QPushButton>
|
||||
#include <QUrl>
|
||||
#include <QWebElement>
|
||||
@ -71,9 +74,7 @@ void GitreportModule::sendReportUsingGitreport(const QMap<QString, QString> info
|
||||
if (debug) qDebug() << "[GitreportModule]" << "[sendReportUsingGitreport]";
|
||||
|
||||
QWebElement document = webView->page()->mainFrame()->documentElement();
|
||||
QWebElement captcha = document.findFirst(QString("input#captcha"));
|
||||
QWebElement captchaImg = document.findFirst(QString("img#[alt=captcha]"));
|
||||
QWebElement captchaKey = document.findFirst(QString("input#captcha_key"));
|
||||
QWebElement captchaKey = document.findFirst(QString("input#captcha"));
|
||||
QWebElement emailInput = document.findFirst(QString("input#email"));
|
||||
QWebElement textArea = document.findFirst(QString("textarea#details"));
|
||||
QWebElement usernameInput = document.findFirst(QString("input#name"));
|
||||
@ -82,12 +83,7 @@ void GitreportModule::sendReportUsingGitreport(const QMap<QString, QString> info
|
||||
usernameInput.setAttribute(QString("value"), info[QString("username")]);
|
||||
emailInput.setAttribute(QString("value"), info[QString("password")]);
|
||||
textArea.setPlainText(info[QString("body")]);
|
||||
// captcha
|
||||
captchaImg.setAttribute(QString("src"), QString("/simple_captcha?code=%1&time=%2")
|
||||
.arg(QString(CAPTCHA_KEY))
|
||||
.arg(QString(CAPTCHA_TIME)));
|
||||
captchaKey.setAttribute(QString("value"), QString(CAPTCHA_KEY));
|
||||
captcha.setAttribute(QString("value"), QString(CAPTCHA_TEXT));
|
||||
captchaKey.setAttribute(QString("value"), info[QString("captcha")]);
|
||||
|
||||
// send request
|
||||
document.findFirst(QString("input[name=commit]")).evaluateJavaScript("this.click()");
|
||||
@ -105,8 +101,17 @@ void GitreportModule::gitreportLoaded(const bool state)
|
||||
if (debug) qDebug() << "[GitreportModule]" << "[gitreportLoaded]";
|
||||
if (debug) qDebug() << "[GitreportModule]" << "[gitreportLoaded]" << ":" << "State" << state;
|
||||
|
||||
if (state)
|
||||
if (state) {
|
||||
webView->setHidden(!debug);
|
||||
// captcha
|
||||
QWebElement document = webView->page()->mainFrame()->documentElement();
|
||||
QWebElement captchaImg = document.findFirst(QString("input#captcha_key"));
|
||||
QString captchaUrl = QString(CAPTCHA_URL) + captchaImg.attribute(QString("value"));
|
||||
QNetworkRequest request(captchaUrl);
|
||||
manager.get(request);
|
||||
disconnect(&manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(setCaptcha(QNetworkReply *)));
|
||||
connect(&manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(setCaptcha(QNetworkReply *)));
|
||||
}
|
||||
else {
|
||||
QMessageBox messageBox;
|
||||
messageBox.setText(QApplication::translate("Reportabug", "Error!"));
|
||||
@ -165,3 +170,20 @@ void GitreportModule::gitreportFinished(const bool state)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn setCaptcha
|
||||
*/
|
||||
void GitreportModule::setCaptcha(QNetworkReply *reply)
|
||||
{
|
||||
if (debug) qDebug() << "[setCaptcha]" << "[setCaptcha]";
|
||||
if (debug) qDebug() << "[setCaptcha]" << "[setCaptcha]" << ":" << "Error state" << reply->error();
|
||||
if (debug) qDebug() << "[setCaptcha]" << "[setCaptcha]" << ":" << "Reply size" << reply->readBufferSize();
|
||||
|
||||
QByteArray answer = reply->readAll();
|
||||
QPixmap captcha;
|
||||
captcha.loadFromData(answer);
|
||||
mainWindow->setCaptchaImage(captcha);
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <QObject>
|
||||
#include <QWebView>
|
||||
|
||||
class QNetworkAccessManager;
|
||||
class Reportabug;
|
||||
|
||||
/**
|
||||
@ -37,7 +38,7 @@ class Reportabug;
|
||||
* creating an issue. Please visit [this page](https://gitreports.com/)
|
||||
* and set up it for your repository.
|
||||
*
|
||||
* This module depends on QtWebKit module.
|
||||
* This module depends on QtWebKit and QtNetwork modules.
|
||||
*/
|
||||
class GitreportModule : public QObject
|
||||
{
|
||||
@ -81,6 +82,11 @@ private slots:
|
||||
* @param bool state of web page loading
|
||||
*/
|
||||
void gitreportLoaded(const bool state);
|
||||
/**
|
||||
* @brief method which will be called after loading captcha image
|
||||
* @param reply reply of the request
|
||||
*/
|
||||
void setCaptcha(QNetworkReply *reply);
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -90,7 +96,11 @@ private:
|
||||
/**
|
||||
* @brief Reportabug class
|
||||
*/
|
||||
Reportabug *mainWindow;;
|
||||
Reportabug *mainWindow;
|
||||
/**
|
||||
* @brief manager for getting captcha
|
||||
*/
|
||||
QNetworkAccessManager manager;
|
||||
};
|
||||
|
||||
|
||||
|
@ -84,6 +84,17 @@ void Reportabug::externalUpdateTab()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn setCaptchaImage
|
||||
*/
|
||||
void Reportabug::setCaptchaImage(QPixmap captcha)
|
||||
{
|
||||
if (debug) qDebug() << "[Reportabug]" << "[setCaptchaImage]";
|
||||
|
||||
ui->label_captcha->setPixmap(captcha);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn createActions
|
||||
*/
|
||||
@ -167,7 +178,7 @@ void Reportabug::initModules()
|
||||
modules[1] = true;
|
||||
gitreport = new GitreportModule(this, debug);
|
||||
// 4 is a magic number. Seriously
|
||||
ui->verticalLayout->insertWidget(4, gitreport->webView);
|
||||
ui->verticalLayout->insertWidget(5, gitreport->webView);
|
||||
#endif /* ENABLE_GITREPORT */
|
||||
#ifdef OWN_GITHUB_TOKEN
|
||||
modules[2] = true;
|
||||
@ -218,6 +229,7 @@ void Reportabug::sendReport()
|
||||
int number = getNumberByIndex(ui->comboBox->currentIndex());
|
||||
QMap<QString, QString> info;
|
||||
info[QString("body")] = ui->textEdit->toPlainText();
|
||||
info[QString("captcha")] = ui->lineEdit_captcha->text();
|
||||
info[QString("password")] = ui->lineEdit_password->text();
|
||||
info[QString("title")] = ui->lineEdit_title->text();
|
||||
info[QString("username")] = ui->lineEdit_username->text();
|
||||
@ -264,6 +276,7 @@ void Reportabug::updateTabs(const int index)
|
||||
ui->lineEdit_password->clear();
|
||||
ui->lineEdit_title->setText(QString(TAG_TITLE));
|
||||
ui->textEdit->setPlainText(QString(TAG_BODY));
|
||||
ui->lineEdit_captcha->clear();
|
||||
|
||||
// it is out of conditional because I don't want a lot of ifdef/endif
|
||||
#ifdef ENABLE_GITREPORT
|
||||
@ -273,12 +286,14 @@ void Reportabug::updateTabs(const int index)
|
||||
ui->widget_auth->setHidden(true);
|
||||
ui->widget_title->setHidden(true);
|
||||
ui->textEdit->setHidden(true);
|
||||
ui->widget_captcha->setHidden(true);
|
||||
}
|
||||
#ifdef ENABLE_GITHUB
|
||||
else if (number == 0) {
|
||||
ui->widget_auth->setHidden(false);
|
||||
ui->widget_title->setHidden(false);
|
||||
ui->textEdit->setHidden(false);
|
||||
ui->widget_captcha->setHidden(true);
|
||||
ui->label_password->setText(QApplication::translate("Reportabug", "Password"));
|
||||
ui->label_password->setToolTip(QApplication::translate("Reportabug", "GitHub account password"));
|
||||
ui->lineEdit_password->setPlaceholderText(QApplication::translate("Reportabug", "password"));
|
||||
@ -290,6 +305,7 @@ void Reportabug::updateTabs(const int index)
|
||||
ui->widget_auth->setHidden(false);
|
||||
ui->widget_title->setHidden(true);
|
||||
ui->textEdit->setHidden(false);
|
||||
ui->widget_captcha->setHidden(false);
|
||||
ui->label_password->setText(QApplication::translate("Reportabug", "Email"));
|
||||
ui->label_password->setToolTip(QApplication::translate("Reportabug", "Your email"));
|
||||
ui->lineEdit_password->setPlaceholderText(QApplication::translate("Reportabug", "email"));
|
||||
|
@ -59,6 +59,11 @@ public:
|
||||
* @brief method which is used for update tabs from external classes
|
||||
*/
|
||||
void externalUpdateTab();
|
||||
/**
|
||||
* @brief method which sets captcha image
|
||||
* @param captcha captcha image
|
||||
*/
|
||||
void setCaptchaImage(QPixmap captcha);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>543</width>
|
||||
<height>374</height>
|
||||
<width>541</width>
|
||||
<height>372</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -109,6 +109,22 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_captcha" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_captcha">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_captcha"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
|
Loading…
Reference in New Issue
Block a user