summaryrefslogtreecommitdiff
path: root/src/plugins/cpaster
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-10-22 15:41:18 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2018-10-22 15:51:57 +0000
commita4c457ea040ad7506b9def642a847b98d68d9959 (patch)
treef1d56ff18775beefdf46dcb3e3728568af78a915 /src/plugins/cpaster
parent33cb73d24e3c7148307c0ae881bb14e5c4f980b4 (diff)
downloadqt-creator-a4c457ea040ad7506b9def642a847b98d68d9959.tar.gz
CodePaster: Remove support for pastebin.ca
It's been returning 503 for months now. Change-Id: I0280a21e6fd7c34b4c9b9c9b118a9e2f61f4a022 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/cpaster')
-rw-r--r--src/plugins/cpaster/cpaster.pro2
-rw-r--r--src/plugins/cpaster/cpaster.qbs2
-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.cpp4
-rw-r--r--src/plugins/cpaster/pastebindotcaprotocol.cpp232
-rw-r--r--src/plugins/cpaster/pastebindotcaprotocol.h65
8 files changed, 0 insertions, 310 deletions
diff --git a/src/plugins/cpaster/cpaster.pro b/src/plugins/cpaster/cpaster.pro
index 6a06056530..fa3a983d3c 100644
--- a/src/plugins/cpaster/cpaster.pro
+++ b/src/plugins/cpaster/cpaster.pro
@@ -6,7 +6,6 @@ HEADERS += cpasterplugin.h \
pasteview.h \
cpasterconstants.h \
pastebindotcomprotocol.h \
- pastebindotcaprotocol.h \
pastecodedotxyzprotocol.h \
settings.h \
pasteselectdialog.h \
@@ -23,7 +22,6 @@ SOURCES += cpasterplugin.cpp \
protocol.cpp \
pasteview.cpp \
pastebindotcomprotocol.cpp \
- pastebindotcaprotocol.cpp \
pastecodedotxyzprotocol.cpp \
settings.cpp \
pasteselectdialog.cpp \
diff --git a/src/plugins/cpaster/cpaster.qbs b/src/plugins/cpaster/cpaster.qbs
index 35bb876034..d8d7726e7a 100644
--- a/src/plugins/cpaster/cpaster.qbs
+++ b/src/plugins/cpaster/cpaster.qbs
@@ -26,8 +26,6 @@ QtcPlugin {
"fileshareprotocolsettingswidget.ui",
"kdepasteprotocol.cpp",
"kdepasteprotocol.h",
- "pastebindotcaprotocol.cpp",
- "pastebindotcaprotocol.h",
"pastebindotcomprotocol.cpp",
"pastebindotcomprotocol.h",
"pastebindotcomsettings.ui",
diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp
index 4a512c2edf..1aad17f851 100644
--- a/src/plugins/cpaster/cpasterplugin.cpp
+++ b/src/plugins/cpaster/cpasterplugin.cpp
@@ -28,7 +28,6 @@
#include "pasteview.h"
#include "kdepasteprotocol.h"
#include "pastebindotcomprotocol.h"
-#include "pastebindotcaprotocol.h"
#include "pastecodedotxyzprotocol.h"
#include "fileshareprotocol.h"
#include "pasteselectdialog.h"
@@ -121,7 +120,6 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *errorMe
// Create the protocols and append them to the Settings
Protocol *protos[] = {new PasteBinDotComProtocol,
- new PasteBinDotCaProtocol,
new KdePasteProtocol,
new FileShareProtocol,
new PasteCodeDotXyzProtocol,
diff --git a/src/plugins/cpaster/frontend/frontend.pro b/src/plugins/cpaster/frontend/frontend.pro
index 70d2e4339d..fc5913b5e8 100644
--- a/src/plugins/cpaster/frontend/frontend.pro
+++ b/src/plugins/cpaster/frontend/frontend.pro
@@ -13,7 +13,6 @@ QT += network
HEADERS = ../protocol.h \
../cpasterconstants.h \
../pastebindotcomprotocol.h \
- ../pastebindotcaprotocol.h \
../pastecodedotxyzprotocol.h \
../kdepasteprotocol.h \
../urlopenprotocol.h \
@@ -21,7 +20,6 @@ HEADERS = ../protocol.h \
SOURCES += ../protocol.cpp \
../pastebindotcomprotocol.cpp \
- ../pastebindotcaprotocol.cpp \
../pastecodedotxyzprotocol.cpp \
../kdepasteprotocol.cpp \
../urlopenprotocol.cpp \
diff --git a/src/plugins/cpaster/frontend/frontend.qbs b/src/plugins/cpaster/frontend/frontend.qbs
index 385c2121a1..b1b1c998e9 100644
--- a/src/plugins/cpaster/frontend/frontend.qbs
+++ b/src/plugins/cpaster/frontend/frontend.qbs
@@ -24,7 +24,6 @@ QtcTool {
files: [
"cpasterconstants.h",
"kdepasteprotocol.h", "kdepasteprotocol.cpp",
- "pastebindotcaprotocol.h", "pastebindotcaprotocol.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 05faa18845..5845334293 100644
--- a/src/plugins/cpaster/frontend/main.cpp
+++ b/src/plugins/cpaster/frontend/main.cpp
@@ -25,7 +25,6 @@
#include "argumentscollector.h"
#include "../kdepasteprotocol.h"
-#include "../pastebindotcaprotocol.h"
#include "../pastebindotcomprotocol.h"
#include "../pastecodedotxyzprotocol.h"
@@ -49,8 +48,6 @@ public:
{
if (protocol == KdePasteProtocol::protocolName().toLower())
m_protocol.reset(new KdePasteProtocol);
- else if (protocol == PasteBinDotCaProtocol::protocolName().toLower())
- m_protocol.reset(new PasteBinDotCaProtocol);
else if (protocol == PasteBinDotComProtocol::protocolName().toLower())
m_protocol.reset(new PasteBinDotComProtocol);
else if (protocol == PasteCodeDotXyzProtocol::protocolName().toLower())
@@ -95,7 +92,6 @@ int main(int argc, char *argv[])
QCoreApplication app(argc, argv);
const QStringList protocols = {KdePasteProtocol::protocolName().toLower(),
- PasteBinDotCaProtocol::protocolName().toLower(),
PasteBinDotComProtocol::protocolName().toLower(),
PasteCodeDotXyzProtocol::protocolName().toLower()};
ArgumentsCollector argsCollector(protocols);
diff --git a/src/plugins/cpaster/pastebindotcaprotocol.cpp b/src/plugins/cpaster/pastebindotcaprotocol.cpp
deleted file mode 100644
index 50d545300e..0000000000
--- a/src/plugins/cpaster/pastebindotcaprotocol.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "pastebindotcaprotocol.h"
-
-#include <utils/qtcassert.h>
-
-#include <QNetworkReply>
-#include <QStringList>
-#include <QJsonArray>
-#include <QJsonDocument>
-#include <QJsonValue>
-#include <QJsonObject>
-
-static const char urlC[] = "https://pastebin.ca/";
-static const char internalUrlC[] = "https://pbin.ca/";
-static const char protocolNameC[] = "Pastebin.Ca";
-
-static inline QByteArray expiryValue(int expiryDays)
-{
- // pastebin.ca supports 1-3 days, 1-3 weeks, 1-6 months, 1 year
- const int months = expiryDays / 30;
- const int weeks = expiryDays / 7;
-
- if (expiryDays == 1)
- return "1 day";
- if (expiryDays < 4)
- return QByteArray::number(expiryDays) + " days";
- if (weeks <= 1)
- return "1 week";
- if (weeks <= 3)
- return QByteArray::number(weeks) + " weeks";
- if (months <= 1)
- return "1 month";
- if (months <= 6)
- return QByteArray::number(months) + " months";
- return "1 year"; // using Never makes the post expire after 1 month
-}
-
-namespace CodePaster {
-
-QString PasteBinDotCaProtocol::protocolName()
-{
- return QLatin1String(protocolNameC);
-}
-
-unsigned PasteBinDotCaProtocol::capabilities() const
-{
- return ListCapability | PostDescriptionCapability | PostCommentCapability;
-}
-
-void PasteBinDotCaProtocol::fetch(const QString &id)
-{
- QTC_ASSERT(!m_fetchReply, return);
- const QString url = QLatin1String(internalUrlC);
- const QString rawPostFix = QLatin1String("raw/");
- // Create link as ""http://pbin.ca/raw/[id]"
- // If we get a complete URL, just insert 'raw', else build URL.
- QString link = id;
- if (link.startsWith(url)) {
- const int lastSlashPos = link.lastIndexOf(QLatin1Char('/'));
- if (lastSlashPos != -1)
- link.insert(lastSlashPos + 1, rawPostFix);
- } else {
- link.insert(0, rawPostFix);
- link.insert(0, url);
- }
- m_fetchReply = httpGet(link);
- connect(m_fetchReply, &QNetworkReply::finished,
- this, &PasteBinDotCaProtocol::fetchFinished);
- m_fetchId = id;
-}
-
-static QByteArray toTypeId(Protocol::ContentType ct)
-{
- if (ct == Protocol::C)
- return QByteArray(1, '3');
- if (ct == Protocol::Cpp)
- return QByteArray(1, '4');
- if (ct == Protocol::JavaScript)
- return QByteArray("27");
- if (ct == Protocol::Diff)
- return QByteArray( "34");
- if (ct == Protocol::Xml)
- return QByteArray("15");
- return QByteArray(1, '1');
-}
-
-void PasteBinDotCaProtocol::paste(const QString &text,
- ContentType ct, int expiryDays,
- const QString &/* username */,
- const QString & comment,
- const QString &description)
-{
- QTC_ASSERT(!m_pasteReply, return);
- QByteArray data = "api=+xKvWG+1UFXkr2Kn3Td4AnpYtCIjA4qt&";
- data += "content=";
- data += QUrl::toPercentEncoding(fixNewLines(text));
- data += "&type=";
- data += toTypeId(ct);
- data += "&description=";
- data += QUrl::toPercentEncoding(comment);
- data += "&expiry=";
- data += QUrl::toPercentEncoding(QLatin1String(expiryValue(expiryDays)));
- data += "&name="; // Title or name.
- data += QUrl::toPercentEncoding(description);
- // fire request
- const QString link = QLatin1String(internalUrlC) + QLatin1String("quiet-paste.php");
- m_pasteReply = httpPost(link, data);
- connect(m_pasteReply, &QNetworkReply::finished,
- this, &PasteBinDotCaProtocol::pasteFinished);
-}
-
-void PasteBinDotCaProtocol::pasteFinished()
-{
- if (m_pasteReply->error()) {
- qWarning("%s protocol error: %s", protocolNameC, qPrintable(m_pasteReply->errorString()));
- } else {
- /// returns ""SUCCESS:[id]""
- const QByteArray data = m_pasteReply->readAll();
- const QString link = QString::fromLatin1(urlC) + QString::fromLatin1(data).remove(QLatin1String("SUCCESS:"));
- emit pasteDone(link);
- }
- m_pasteReply->deleteLater();
- m_pasteReply = 0;
-}
-
-void PasteBinDotCaProtocol::fetchFinished()
-{
- QString title;
- QString content;
- bool error = m_fetchReply->error();
- if (error) {
- content = m_fetchReply->errorString();
- } else {
- title = name() + QLatin1String(": ") + m_fetchId;
- const QByteArray data = m_fetchReply->readAll();
- content = QString::fromUtf8(data);
- content.remove(QLatin1Char('\r'));
- }
- m_fetchReply->deleteLater();
- m_fetchReply = 0;
- emit fetchDone(title, content, error);
-}
-
-void PasteBinDotCaProtocol::list()
-{
- QTC_ASSERT(!m_listReply, return);
- m_listReply = httpGet(QLatin1String(urlC));
- connect(m_listReply, &QNetworkReply::finished, this, &PasteBinDotCaProtocol::listFinished);
-}
-
-bool PasteBinDotCaProtocol::checkConfiguration(QString *errorMessage)
-{
- if (m_hostChecked) // Check the host once.
- return true;
- const bool ok = httpStatus(QLatin1String(urlC), errorMessage);
- if (ok)
- m_hostChecked = true;
- return ok;
-}
-
-/* Quick & dirty: Parse page does no more work due to internal javascript/websocket magic - so,
- * search for _initial_ json array containing the last added pastes.
-\code
-<script type="text/javascript">var pHistoryInitial = [{"id":3791300,"ts":1491288268,"name":"try",
-"expires":1491374668},
-\endcode */
-
-static inline QStringList parseLists(QIODevice *io)
-{
- QStringList rc;
-
- QByteArray data = io->readAll();
- const QByteArray history("<script type=\"text/javascript\">var pHistoryInitial = ");
- int pos = data.indexOf(history);
- if (pos == -1)
- return rc;
- data.remove(0, pos + history.size());
- pos = data.indexOf(";</script>");
- if (pos == -1)
- return rc;
- data.truncate(pos);
- QJsonParseError error;
- const QJsonDocument doc = QJsonDocument::fromJson(data, &error);
- if (error.error != QJsonParseError::NoError)
- return rc;
- QJsonArray array = doc.array();
- for (const QJsonValue &val : array) {
- const QJsonObject obj = val.toObject();
- const QJsonValue id = obj.value("id");
- const QJsonValue name = obj.value("name");
- if (!id.isUndefined())
- rc.append(QString::number(id.toInt()) + ' ' + name.toString());
- }
- return rc;
-}
-
-void PasteBinDotCaProtocol::listFinished()
-{
- const bool error = m_listReply->error();
- if (error)
- qWarning("%s list failed: %s", protocolNameC, qPrintable(m_listReply->errorString()));
- else
- emit listDone(name(), parseLists(m_listReply));
- m_listReply->deleteLater();
- m_listReply = nullptr;
-}
-
-} // namespace CodePaster
diff --git a/src/plugins/cpaster/pastebindotcaprotocol.h b/src/plugins/cpaster/pastebindotcaprotocol.h
deleted file mode 100644
index b46b8fcfbe..0000000000
--- a/src/plugins/cpaster/pastebindotcaprotocol.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "protocol.h"
-
-namespace CodePaster {
-class PasteBinDotCaProtocol : public NetworkProtocol
-{
- Q_OBJECT
-public:
- static QString protocolName();
- QString name() const override { return protocolName(); }
-
- bool hasSettings() const override { return false; }
- unsigned capabilities() const override;
-
- void fetch(const QString &id) override;
- void paste(const QString &text,
- ContentType ct = Text,
- int expiryDays = 1,
- const QString &username = QString(),
- const QString &comment = QString(),
- const QString &description = QString()) override;
- void list() override;
-
-protected:
- bool checkConfiguration(QString *errorMessage) override;
-
-private:
- void fetchFinished();
- void listFinished();
- void pasteFinished();
-
- QNetworkReply *m_fetchReply = nullptr;
- QNetworkReply *m_listReply = nullptr;
- QNetworkReply *m_pasteReply = nullptr;
- QString m_fetchId;
- bool m_hostChecked = false;
-};
-
-} // namespace CodePaster