diff --git a/applets/pastebin/pastebinConfig.ui b/applets/pastebin/pastebinConfig.ui
index b127f44..cbd97a0 100644
--- a/applets/pastebin/pastebinConfig.ui
+++ b/applets/pastebin/pastebinConfig.ui
@@ -65,6 +65,11 @@
Pastebin.com
+ -
+
+ Wklej.org
+
+
-
@@ -118,6 +123,11 @@
Simplest-Image-Hosting.net
+ -
+
+ Wstaw.org
+
+
-
diff --git a/dataengines/pastebin/CMakeLists.txt b/dataengines/pastebin/CMakeLists.txt
index f21b81b..ae34207 100644
--- a/dataengines/pastebin/CMakeLists.txt
+++ b/dataengines/pastebin/CMakeLists.txt
@@ -7,6 +7,8 @@ set(pastebin_engine_SRCS
backends/imagebinca.cpp
backends/imageshack.cpp
backends/simplestimagehosting.cpp
+ backends/wklejorg.cpp
+ backends/wstaworg.cpp
pastebinengine.cpp
pastebinservice.cpp)
diff --git a/dataengines/pastebin/backends/backends.h b/dataengines/pastebin/backends/backends.h
index a922615..b0348da 100644
--- a/dataengines/pastebin/backends/backends.h
+++ b/dataengines/pastebin/backends/backends.h
@@ -25,5 +25,7 @@
#include "imagebinca.h"
#include "imageshack.h"
#include "simplestimagehosting.h"
+#include "wklejorg.h"
+#include "wstaworg.h"
#endif
diff --git a/dataengines/pastebin/backends/wklejorg.cpp b/dataengines/pastebin/backends/wklejorg.cpp
new file mode 100644
index 0000000..f25b208
--- /dev/null
+++ b/dataengines/pastebin/backends/wklejorg.cpp
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Artur Duque de Souza *
+ * Michał Ziąbkowski *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
+ ***************************************************************************/
+
+#include "wklejorg.h"
+
+#include
+#include
+
+WklejORGServer::WklejORGServer(const QString &server)
+{
+ if (server.isEmpty()) {
+ m_server = WKLEJORG_SERVER;
+ } else {
+ m_server = server;
+ }
+
+ first = true;
+}
+
+WklejORGServer::~WklejORGServer()
+{
+}
+
+void WklejORGServer::result(KIO::Job *job, const KUrl &url)
+{
+ // work around the double redirect
+ if (first) {
+ first = false;
+ return;
+ }
+
+ Q_UNUSED(job);
+
+ if (!url.url().contains("/id/")) {
+ // we had an error
+ emit postError();
+ return;
+ }
+
+ emit postFinished(url.url());
+}
+
+void WklejORGServer::post(const QString& content)
+{
+ QByteArray bytearray = "body=";
+ bytearray.append(QUrl::toPercentEncoding(content,"/"));
+ bytearray.append("&autor=&syntax=text&isprivate=");
+
+ QString url(m_server);
+
+ KIO::TransferJob *tf = KIO::http_post(KUrl(url),
+ bytearray,KIO::HideProgressInfo);
+
+ tf->addMetaData("content-type","Content-Type: application/x-www-form-urlencoded");
+ connect(tf, SIGNAL(redirection(KIO::Job*, const KUrl&)),
+ this, SLOT(result(KIO::Job*, const KUrl&)));
+
+}
diff --git a/dataengines/pastebin/backends/wklejorg.h b/dataengines/pastebin/backends/wklejorg.h
new file mode 100644
index 0000000..e83e0af
--- /dev/null
+++ b/dataengines/pastebin/backends/wklejorg.h
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Artur Duque de Souza *
+ * Michał Ziąbkowski *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
+ ***************************************************************************/
+
+#ifndef WKLEJORG_H
+#define WKLEJORG_H
+
+#include "server.h"
+
+#include
+
+#include
+#include
+
+#define WKLEJORG_SERVER "http://wklej.org"
+
+class WklejORGServer : public PastebinServer
+{
+ Q_OBJECT
+
+public:
+ WklejORGServer(const QString &server = WKLEJORG_SERVER);
+ virtual ~WklejORGServer();
+
+ virtual void post(const QString& content);
+private:
+ bool first;
+
+public slots:
+ void result(KIO::Job *job, const KUrl &url);
+};
+
+#endif
diff --git a/dataengines/pastebin/backends/wstaworg.cpp b/dataengines/pastebin/backends/wstaworg.cpp
new file mode 100644
index 0000000..6b4c117
--- /dev/null
+++ b/dataengines/pastebin/backends/wstaworg.cpp
@@ -0,0 +1,141 @@
+/***************************************************************************
+ * Copyright (C) 2009 by Artur Duque de Souza *
+ * Vardhman Jain *
+ * Gilles Caulier *
+ * Michał Ziąbkowski *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
+ ***************************************************************************/
+
+#include "wstaworg.h"
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+WstawORGServer::WstawORGServer(const QString &server)
+{
+ if (server.isEmpty()) {
+ m_server = WSTAWORG_SERVER;
+ } else {
+ m_server = server;
+ }
+
+ first = true;
+ m_boundary = "----------";
+ m_boundary += KRandom::randomString(42 + 13).toAscii();
+}
+
+WstawORGServer::~WstawORGServer()
+{
+}
+
+// taken from flickr KIPI Plugin
+void WstawORGServer::finish()
+{
+ QByteArray str;
+ str += "--";
+ str += m_boundary;
+ str += "--";
+
+ m_buffer.append(str);
+}
+
+// taken from flickr KIPI Plugin
+bool WstawORGServer::addFile(const QString& name,const QString& path)
+{
+ KMimeType::Ptr ptr = KMimeType::findByUrl(path);
+ QString mime = ptr->name();
+ if (mime.isEmpty()) {
+ // if we ourselves can't determine the mime of the local file,
+ // very unlikely the remote site will be able to identify it
+ return false;
+ }
+
+ QFile imageFile(path);
+ if (!imageFile.open(QIODevice::ReadOnly)) {
+ return false;
+ }
+
+ QByteArray imageData = imageFile.readAll();
+ imageFile.close();
+
+ QByteArray str;
+
+ str += "--";
+ str += m_boundary;
+ str += "\r\n";
+ str += "Content-Disposition: form-data; name=\"";
+ str += name.toAscii();
+ str += "\"; ";
+ str += "filename=\"";
+ str += QFile::encodeName(KUrl(path).fileName()).replace(".tmp", ".jpg");
+ str += "\"";
+ str += "\r\n";
+ str += "Content-Type: ";
+ str += mime.toAscii();
+ str += "\r\n\r\n";
+
+ m_buffer.append(str);
+
+ int oldSize = m_buffer.size();
+ m_buffer.resize(oldSize + imageData.size() + 2);
+ memcpy(m_buffer.data() + oldSize, imageData.data(), imageData.size());
+ m_buffer[m_buffer.size()-2] = '\r';
+ m_buffer[m_buffer.size()-1] = '\n';
+
+ return true;
+}
+
+void WstawORGServer::result(KIO::Job *job, const KUrl &url)
+{
+ // work around the double redirect
+ if (first) {
+ first = false;
+ return;
+ }
+
+ Q_UNUSED(job);
+
+ if (!url.url().contains("/linki/")) {
+ // we had an error
+ emit postError();
+ return;
+ }
+
+ emit postFinished(url.url());
+}
+
+void WstawORGServer::post(const QString& content)
+{
+ KUrl url(m_server);
+
+ addFile("pic", content);
+ finish();
+
+ first = true;
+ KIO::TransferJob *tf = KIO::http_post(url, m_buffer, KIO::HideProgressInfo);
+
+ tf->addMetaData("content-type","Content-Type: multipart/form-data; boundary=" + m_boundary);
+
+ connect(tf, SIGNAL(redirection(KIO::Job*, const KUrl&)),
+ this, SLOT(result(KIO::Job*, const KUrl&)));
+}
diff --git a/dataengines/pastebin/backends/wstaworg.h b/dataengines/pastebin/backends/wstaworg.h
new file mode 100644
index 0000000..6e40891
--- /dev/null
+++ b/dataengines/pastebin/backends/wstaworg.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * Copyright (C) 2009 by Thomas Georgiou *
+ * Artur Duque de Souza *
+ * Michał Ziąbkowski *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
+ ***************************************************************************/
+
+#ifndef WstawORG_H
+#define WstawORG_H
+
+#include "server.h"
+
+#include
+
+#include
+#include
+
+#define WSTAWORG_SERVER "http://wstaw.org"
+
+class WstawORGServer : public PastebinServer
+{
+ Q_OBJECT
+
+public:
+ WstawORGServer(const QString &server = WSTAWORG_SERVER);
+ virtual ~WstawORGServer();
+
+ virtual void post(const QString& content);
+
+ void finish();
+ bool addFile(const QString& name,const QString& path);
+
+protected:
+ QByteArray m_buffer;
+ QByteArray m_boundary;
+
+public slots:
+ void result(KIO::Job *job, const KUrl &url);
+
+private:
+ bool first;
+};
+
+#endif
diff --git a/dataengines/pastebin/pastebinservice.cpp b/dataengines/pastebin/pastebinservice.cpp
index 0881490..094b084 100644
--- a/dataengines/pastebin/pastebinservice.cpp
+++ b/dataengines/pastebin/pastebinservice.cpp
@@ -50,6 +50,10 @@ Plasma::ServiceJob *PastebinService::createJob(const QString &operation,
case PastebinService::PASTEBINCOM:
m_textServer = new PastebinCOMServer(server);
break;
+
+ case PastebinService::WKLEJORG:
+ m_textServer = new WklejORGServer(server);
+ break;
}
connect(m_textServer, SIGNAL(postFinished(QString)),
@@ -74,6 +78,10 @@ Plasma::ServiceJob *PastebinService::createJob(const QString &operation,
case PastebinService::SIMPLESTIMAGEHOSTING:
m_imageServer = new SimplestImageHostingServer(server);
break;
+
+ case PastebinService::WSTAWORG:
+ m_imageServer = new WstawORGServer(server);
+ break;
}
connect(m_imageServer, SIGNAL(postFinished(QString)),
diff --git a/dataengines/pastebin/pastebinservice.h b/dataengines/pastebin/pastebinservice.h
index ea3baa7..f12c8a3 100644
--- a/dataengines/pastebin/pastebinservice.h
+++ b/dataengines/pastebin/pastebinservice.h
@@ -38,8 +38,8 @@ class PastebinService : public Plasma::Service
Q_OBJECT
public:
- enum textServers { PASTEBINCA, PASTEBINCOM };
- enum imageServers { IMAGEBINCA, IMAGESHACK, SIMPLESTIMAGEHOSTING };
+ enum textServers { PASTEBINCA, PASTEBINCOM, WKLEJORG };
+ enum imageServers { IMAGEBINCA, IMAGESHACK, SIMPLESTIMAGEHOSTING, WSTAWORG };
PastebinService(PastebinEngine *engine);
Plasma::ServiceJob *createJob(const QString &operation,