aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/editors/creator-only/creator-code-pasting.qdoc1
-rw-r--r--src/plugins/cpaster/authenticationdialog.cpp64
-rw-r--r--src/plugins/cpaster/authenticationdialog.h53
-rw-r--r--src/plugins/cpaster/cpaster.pro10
-rw-r--r--src/plugins/cpaster/cpaster.qbs6
-rw-r--r--src/plugins/cpaster/cpasterplugin.cpp2
-rw-r--r--src/plugins/cpaster/frontend/frontend.pro2
-rw-r--r--src/plugins/cpaster/frontend/frontend.qbs1
-rw-r--r--src/plugins/cpaster/frontend/main.cpp8
-rw-r--r--src/plugins/cpaster/protocol.cpp31
-rw-r--r--src/plugins/cpaster/protocol.h8
-rw-r--r--src/plugins/cpaster/stickynotespasteprotocol.cpp (renamed from src/plugins/cpaster/kdepasteprotocol.cpp)127
-rw-r--r--src/plugins/cpaster/stickynotespasteprotocol.h (renamed from src/plugins/cpaster/kdepasteprotocol.h)31
13 files changed, 10 insertions, 334 deletions
diff --git a/doc/src/editors/creator-only/creator-code-pasting.qdoc b/doc/src/editors/creator-only/creator-code-pasting.qdoc
index 803a15e64aa..b518c8ca3f2 100644
--- a/doc/src/editors/creator-only/creator-code-pasting.qdoc
+++ b/doc/src/editors/creator-only/creator-code-pasting.qdoc
@@ -38,7 +38,6 @@
\list
\li \uicontrol {Pastebin.Com}
\li \uicontrol {Pastecode.Xyz}
- \li \uicontrol {Paste.KDE.Org}
\li \uicontrol {Shared network drives}
\endlist
diff --git a/src/plugins/cpaster/authenticationdialog.cpp b/src/plugins/cpaster/authenticationdialog.cpp
deleted file mode 100644
index 326cdb2d80b..00000000000
--- a/src/plugins/cpaster/authenticationdialog.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "authenticationdialog.h"
-
-#include <QDialogButtonBox>
-#include <QFormLayout>
-#include <QLabel>
-#include <QLineEdit>
-#include <QVBoxLayout>
-
-namespace CodePaster {
-
-AuthenticationDialog::AuthenticationDialog(const QString &details, QWidget *parent)
- : QDialog(parent)
-{
- setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
- auto *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(new QLabel(details));
- auto *formLayout = new QFormLayout;
- formLayout->addRow(tr("Username:"), m_user = new QLineEdit);
- formLayout->addRow(tr("Password:"), m_pass = new QLineEdit);
- m_pass->setEchoMode(QLineEdit::Password);
- mainLayout->addLayout(formLayout);
- auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
- mainLayout->addWidget(buttonBox);
- setLayout(mainLayout);
-}
-
-QString AuthenticationDialog::userName() const
-{
- return m_user->text();
-}
-
-QString AuthenticationDialog::password() const
-{
- return m_pass->text();
-}
-
-} // namespace CodePaster
diff --git a/src/plugins/cpaster/authenticationdialog.h b/src/plugins/cpaster/authenticationdialog.h
deleted file mode 100644
index abab5b515e7..00000000000
--- a/src/plugins/cpaster/authenticationdialog.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-class QLineEdit;
-QT_END_NAMESPACE
-
-namespace CodePaster {
-
-class AuthenticationDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- AuthenticationDialog(const QString &details, QWidget *parent = nullptr);
-
- bool authenticated() const { return m_authenticated; }
- QString userName() const;
- QString password() const;
-
-private:
- bool m_authenticated = false;
- QLineEdit *m_user = nullptr;
- QLineEdit *m_pass = nullptr;
-};
-
-} // namespace CodePaster
diff --git a/src/plugins/cpaster/cpaster.pro b/src/plugins/cpaster/cpaster.pro
index fa3a983d3c4..3565f4d03f0 100644
--- a/src/plugins/cpaster/cpaster.pro
+++ b/src/plugins/cpaster/cpaster.pro
@@ -12,10 +12,9 @@ HEADERS += cpasterplugin.h \
columnindicatortextedit.h \
fileshareprotocol.h \
fileshareprotocolsettingspage.h \
- kdepasteprotocol.h \
+ stickynotespasteprotocol.h \
urlopenprotocol.h \
- codepasterservice.h \
- authenticationdialog.h
+ codepasterservice.h
SOURCES += cpasterplugin.cpp \
settingspage.cpp \
@@ -28,9 +27,8 @@ SOURCES += cpasterplugin.cpp \
columnindicatortextedit.cpp \
fileshareprotocol.cpp \
fileshareprotocolsettingspage.cpp \
- kdepasteprotocol.cpp \
- urlopenprotocol.cpp \
- authenticationdialog.cpp
+ stickynotespasteprotocol.cpp \
+ urlopenprotocol.cpp
FORMS += settingspage.ui \
pasteselect.ui \
diff --git a/src/plugins/cpaster/cpaster.qbs b/src/plugins/cpaster/cpaster.qbs
index d8d7726e7a7..9547f8ad5e3 100644
--- a/src/plugins/cpaster/cpaster.qbs
+++ b/src/plugins/cpaster/cpaster.qbs
@@ -24,8 +24,6 @@ QtcPlugin {
"fileshareprotocolsettingspage.cpp",
"fileshareprotocolsettingspage.h",
"fileshareprotocolsettingswidget.ui",
- "kdepasteprotocol.cpp",
- "kdepasteprotocol.h",
"pastebindotcomprotocol.cpp",
"pastebindotcomprotocol.h",
"pastebindotcomsettings.ui",
@@ -44,10 +42,10 @@ QtcPlugin {
"settingspage.cpp",
"settingspage.h",
"settingspage.ui",
+ "stickynotespasteprotocol.cpp",
+ "stickynotespasteprotocol.h",
"urlopenprotocol.cpp",
"urlopenprotocol.h",
- "authenticationdialog.cpp",
- "authenticationdialog.h"
]
Group {
diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp
index a101598e8bf..13c4faabe36 100644
--- a/src/plugins/cpaster/cpasterplugin.cpp
+++ b/src/plugins/cpaster/cpasterplugin.cpp
@@ -26,7 +26,6 @@
#include "cpasterplugin.h"
#include "pasteview.h"
-#include "kdepasteprotocol.h"
#include "pastebindotcomprotocol.h"
#include "pastecodedotxyzprotocol.h"
#include "fileshareprotocol.h"
@@ -120,7 +119,6 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *errorMe
// Create the protocols and append them to the Settings
Protocol *protos[] = {new PasteBinDotComProtocol,
- new KdePasteProtocol,
new FileShareProtocol,
new PasteCodeDotXyzProtocol,
};
diff --git a/src/plugins/cpaster/frontend/frontend.pro b/src/plugins/cpaster/frontend/frontend.pro
index fc5913b5e8a..69b6428a3f6 100644
--- a/src/plugins/cpaster/frontend/frontend.pro
+++ b/src/plugins/cpaster/frontend/frontend.pro
@@ -14,14 +14,12 @@ HEADERS = ../protocol.h \
../cpasterconstants.h \
../pastebindotcomprotocol.h \
../pastecodedotxyzprotocol.h \
- ../kdepasteprotocol.h \
../urlopenprotocol.h \
argumentscollector.h
SOURCES += ../protocol.cpp \
../pastebindotcomprotocol.cpp \
../pastecodedotxyzprotocol.cpp \
- ../kdepasteprotocol.cpp \
../urlopenprotocol.cpp \
argumentscollector.cpp \
main.cpp
diff --git a/src/plugins/cpaster/frontend/frontend.qbs b/src/plugins/cpaster/frontend/frontend.qbs
index b1b1c998e95..29939531058 100644
--- a/src/plugins/cpaster/frontend/frontend.qbs
+++ b/src/plugins/cpaster/frontend/frontend.qbs
@@ -23,7 +23,6 @@ QtcTool {
prefix: "../"
files: [
"cpasterconstants.h",
- "kdepasteprotocol.h", "kdepasteprotocol.cpp",
"pastebindotcomprotocol.h", "pastebindotcomprotocol.cpp",
"pastecodedotxyzprotocol.h", "pastecodedotxyzprotocol.cpp",
"protocol.h", "protocol.cpp",
diff --git a/src/plugins/cpaster/frontend/main.cpp b/src/plugins/cpaster/frontend/main.cpp
index 5845334293c..50ae182334f 100644
--- a/src/plugins/cpaster/frontend/main.cpp
+++ b/src/plugins/cpaster/frontend/main.cpp
@@ -24,7 +24,6 @@
****************************************************************************/
#include "argumentscollector.h"
-#include "../kdepasteprotocol.h"
#include "../pastebindotcomprotocol.h"
#include "../pastecodedotxyzprotocol.h"
@@ -46,9 +45,7 @@ class PasteReceiver : public QObject
public:
PasteReceiver(const QString &protocol, const QString &filePath) : m_filePath(filePath)
{
- if (protocol == KdePasteProtocol::protocolName().toLower())
- m_protocol.reset(new KdePasteProtocol);
- else if (protocol == PasteBinDotComProtocol::protocolName().toLower())
+ if (protocol == PasteBinDotComProtocol::protocolName().toLower())
m_protocol.reset(new PasteBinDotComProtocol);
else if (protocol == PasteCodeDotXyzProtocol::protocolName().toLower())
m_protocol.reset(new PasteCodeDotXyzProtocol);
@@ -91,8 +88,7 @@ int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
- const QStringList protocols = {KdePasteProtocol::protocolName().toLower(),
- PasteBinDotComProtocol::protocolName().toLower(),
+ const QStringList protocols = {PasteBinDotComProtocol::protocolName().toLower(),
PasteCodeDotXyzProtocol::protocolName().toLower()};
ArgumentsCollector argsCollector(protocols);
QStringList arguments = QCoreApplication::arguments();
diff --git a/src/plugins/cpaster/protocol.cpp b/src/plugins/cpaster/protocol.cpp
index ba0b4b7ec32..b2b1e737929 100644
--- a/src/plugins/cpaster/protocol.cpp
+++ b/src/plugins/cpaster/protocol.cpp
@@ -24,9 +24,6 @@
****************************************************************************/
#include "protocol.h"
-#ifdef CPASTER_PLUGIN_GUI
-#include "authenticationdialog.h"
-#endif
#include <utils/networkaccessmanager.h>
@@ -50,7 +47,6 @@
#include <QMessageBox>
#include <QApplication>
#include <QPushButton>
-#include <QAuthenticator>
namespace CodePaster {
@@ -207,35 +203,8 @@ QNetworkReply *NetworkProtocol::httpPost(const QString &link, const QByteArray &
return Utils::NetworkAccessManager::instance()->post(r, data);
}
-NetworkProtocol::NetworkProtocol()
- : Protocol()
-{
- connect(Utils::NetworkAccessManager::instance(), &QNetworkAccessManager::authenticationRequired,
- this, &NetworkProtocol::authenticationRequired);
-}
-
NetworkProtocol::~NetworkProtocol() = default;
-void NetworkProtocol::requestAuthentication(const QUrl &url, QNetworkReply *reply, QAuthenticator *authenticator)
-{
-#ifdef CPASTER_PLUGIN_GUI
- if (reply->request().url().host() == url.host()) {
- const QString details = tr("Pasting needs authentication.<br/>"
- "Enter your identity credentials to continue.");
- AuthenticationDialog authDialog(details, Core::ICore::dialogParent());
- authDialog.setWindowTitle(tr("Authenticate for Paster"));
- if (authDialog.exec() == QDialog::Accepted) {
- authenticator->setUser(authDialog.userName());
- authenticator->setPassword(authDialog.password());
- }
- }
-#else
- Q_UNUSED(url);
- Q_UNUSED(reply);
- Q_UNUSED(authenticator);
-#endif
-}
-
bool NetworkProtocol::httpStatus(QString url, QString *errorMessage, bool useHttps)
{
// Connect to host and display a message box, using its event loop.
diff --git a/src/plugins/cpaster/protocol.h b/src/plugins/cpaster/protocol.h
index 0b1392656ae..c315a673d1c 100644
--- a/src/plugins/cpaster/protocol.h
+++ b/src/plugins/cpaster/protocol.h
@@ -30,7 +30,6 @@
#include <QSharedPointer>
QT_BEGIN_NAMESPACE
-class QAuthenticator;
class QNetworkReply;
class QWidget;
QT_END_NAMESPACE
@@ -108,16 +107,11 @@ class NetworkProtocol : public Protocol
Q_OBJECT
public:
- NetworkProtocol();
+ NetworkProtocol() = default;
~NetworkProtocol() override;
-signals:
- void authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator);
-
protected:
- void requestAuthentication(const QUrl &url, QNetworkReply *reply, QAuthenticator *authenticator);
-
QNetworkReply *httpGet(const QString &url, bool handleCookies = false);
QNetworkReply *httpPost(const QString &link, const QByteArray &data,
diff --git a/src/plugins/cpaster/kdepasteprotocol.cpp b/src/plugins/cpaster/stickynotespasteprotocol.cpp
index 030b30e0e5f..3ec958d99c3 100644
--- a/src/plugins/cpaster/kdepasteprotocol.cpp
+++ b/src/plugins/cpaster/stickynotespasteprotocol.cpp
@@ -23,9 +23,8 @@
**
****************************************************************************/
-#include "kdepasteprotocol.h"
+#include "stickynotespasteprotocol.h"
#ifdef CPASTER_PLUGIN_GUI
-#include "authenticationdialog.h"
#endif
#include <coreplugin/icore.h>
@@ -266,129 +265,5 @@ void StickyNotesPasteProtocol::listFinished()
m_listReply = nullptr;
}
-KdePasteProtocol::KdePasteProtocol()
-{
- setHostUrl(QLatin1String("https://pastebin.kde.org/"));
- connect(this, &KdePasteProtocol::authenticationFailed, this, [this] () {
- m_loginFailed = true;
- paste(m_text, m_contentType, m_expiryDays, QString(), QString(), m_description);
- });
-}
-
-void KdePasteProtocol::paste(const QString &text, Protocol::ContentType ct, int expiryDays,
- const QString &username, const QString &comment,
- const QString &description)
-{
- Q_UNUSED(username);
- Q_UNUSED(comment);
- // KDE paster needs authentication nowadays
-#ifdef CPASTER_PLUGIN_GUI
- QString details = tr("Pasting to KDE paster needs authentication.<br/>"
- "Enter your KDE Identity credentials to continue.");
- if (m_loginFailed)
- details.prepend("<span style='background-color:LightYellow;color:red'>"
- + tr("Login failed") + "</span><br/><br/>");
-
- AuthenticationDialog authDialog(details, Core::ICore::dialogParent());
- authDialog.setWindowTitle("Authenticate for KDE paster");
- if (authDialog.exec() != QDialog::Accepted) {
- m_loginFailed = false;
- return;
- }
- const QString user = authDialog.userName();
- const QString passwd = authDialog.password();
-#else
- // FIXME get the credentials for the cmdline cpaster somehow
- const QString user;
- const QString passwd;
- qDebug() << "KDE needs credentials for pasting";
- emit pasteDone(QString());
- return;
-#endif
- // store input data as members to be able to use them after the authentication succeeded
- m_text = text;
- m_contentType = ct;
- m_expiryDays = expiryDays;
- m_description = description;
- authenticate(user, passwd);
-}
-
-QString KdePasteProtocol::protocolName()
-{
- return QLatin1String("Paste.KDE.Org");
-}
-
-void KdePasteProtocol::authenticate(const QString &user, const QString &passwd)
-{
- QTC_ASSERT(!m_authReply, return);
-
- // first we need to obtain the hidden form token for logging in
- m_authReply = httpGet(hostUrl() + "user/login");
- connect(m_authReply, &QNetworkReply::finished, this, [this, user, passwd] () {
- onPreAuthFinished(user, passwd);
- });
-}
-
-void KdePasteProtocol::onPreAuthFinished(const QString &user, const QString &passwd)
-{
- if (m_authReply->error() != QNetworkReply::NoError) {
- m_authReply->deleteLater();
- m_authReply = nullptr;
- return;
- }
- const QByteArray page = m_authReply->readAll();
- m_authReply->deleteLater();
- const QRegularExpression regex("name=\"_token\"\\s+type=\"hidden\"\\s+value=\"(.*?)\">");
- const QRegularExpressionMatch match = regex.match(QLatin1String(page));
- if (!match.hasMatch()) {
- m_authReply = nullptr;
- return;
- }
- const QString token = match.captured(1);
-
- QByteArray data("username=" + QUrl::toPercentEncoding(user)
- + "&password=" + QUrl::toPercentEncoding(passwd)
- + "&_token=" + QUrl::toPercentEncoding(token));
- m_authReply = httpPost(hostUrl() + "user/login", data, true);
- connect(m_authReply, &QNetworkReply::finished, this, &KdePasteProtocol::onAuthFinished);
-}
-
-void KdePasteProtocol::onAuthFinished()
-{
- if (m_authReply->error() != QNetworkReply::NoError) {
- m_authReply->deleteLater();
- m_authReply = nullptr;
- return;
- }
- const QVariant attribute = m_authReply->attribute(QNetworkRequest::RedirectionTargetAttribute);
- m_redirectUrl = redirectUrl(attribute.toUrl().toString(), m_redirectUrl);
- if (!m_redirectUrl.isEmpty()) { // we need to perform a redirect
- QUrl url(m_redirectUrl);
- if (url.path().isEmpty())
- url.setPath("/"); // avoid issue inside cookiesForUrl()
- m_authReply->deleteLater();
- m_authReply = httpGet(url.url(), true);
- connect(m_authReply, &QNetworkReply::finished, this, &KdePasteProtocol::onAuthFinished);
- } else { // auth should be done now
- const QByteArray page = m_authReply->readAll();
- m_authReply->deleteLater();
- m_authReply = nullptr;
- if (page.contains("https://identity.kde.org")) // we're back on the login page
- emit authenticationFailed();
- else {
- m_loginFailed = false;
- StickyNotesPasteProtocol::paste(m_text, m_contentType, m_expiryDays, QString(),
- QString(), m_description);
- }
- }
-}
-
-QString KdePasteProtocol::redirectUrl(const QString &redirect, const QString &oldRedirect) const
-{
- QString redirectUrl;
- if (!redirect.isEmpty() && redirect != oldRedirect)
- redirectUrl = redirect;
- return redirectUrl;
-}
} // namespace CodePaster
diff --git a/src/plugins/cpaster/kdepasteprotocol.h b/src/plugins/cpaster/stickynotespasteprotocol.h
index c1875b14772..584c90a921c 100644
--- a/src/plugins/cpaster/kdepasteprotocol.h
+++ b/src/plugins/cpaster/stickynotespasteprotocol.h
@@ -68,35 +68,4 @@ private:
bool m_hostChecked = false;
};
-class KdePasteProtocol : public StickyNotesPasteProtocol
-{
- Q_OBJECT
-public:
- KdePasteProtocol();
-
- void paste(const QString &text, ContentType ct = Text, int expiryDays = 1,
- const QString &username = QString(),
- const QString &comment = QString() ,
- const QString &description = QString()) override;
-
- QString name() const override { return protocolName(); }
- static QString protocolName();
-signals:
- void authenticationFailed();
-private:
- void authenticate(const QString &user, const QString &passwd);
- void onPreAuthFinished(const QString &user, const QString &passwd);
- void onAuthFinished();
- QString redirectUrl(const QString &redirect, const QString &oldRedirect) const;
-
- QNetworkReply *m_authReply = nullptr;
- QString m_text;
- ContentType m_contentType = Text;
- int m_expiryDays = 1;
- bool m_loginFailed = false;
- QString m_description;
- QString m_redirectUrl;
-
-};
-
} // namespace CodePaster