summaryrefslogtreecommitdiffstats
path: root/src/tor_ioslave
diff options
context:
space:
mode:
Diffstat (limited to 'src/tor_ioslave')
-rw-r--r--src/tor_ioslave/Makefile.am15
-rw-r--r--src/tor_ioslave/torioslave.cpp167
-rw-r--r--src/tor_ioslave/torioslave.h43
-rw-r--r--src/tor_ioslave/torioslave.lsm16
-rw-r--r--src/tor_ioslave/torioslave.protocol29
5 files changed, 270 insertions, 0 deletions
diff --git a/src/tor_ioslave/Makefile.am b/src/tor_ioslave/Makefile.am
new file mode 100644
index 0000000..c64d2ff
--- /dev/null
+++ b/src/tor_ioslave/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = $(all_includes)
+LIBS =
+
+kde_module_LTLIBRARIES = kio_torioslave.la
+
+kio_torioslave_la_SOURCES = torioslave.cpp
+kio_torioslave_la_LIBADD = -lkio
+kio_torioslave_la_LDFLAGS = -module -avoid-version $(all_libraries) $(KDE_PLUGIN)
+
+protocol_DATA = torioslave.protocol
+protocoldir = $(kde_servicesdir)
+
+messages: rc.cpp
+ $(EXTRACTRC) `find . -name \*.ui -o -name \*.rc` > rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kio_torioslave.pot
diff --git a/src/tor_ioslave/torioslave.cpp b/src/tor_ioslave/torioslave.cpp
new file mode 100644
index 0000000..961b1d0
--- /dev/null
+++ b/src/tor_ioslave/torioslave.cpp
@@ -0,0 +1,167 @@
+/***************************************************************************
+** $Id: torioslave.cpp,v 1.7 2008/07/31 19:56:29 hoganrobert Exp $
+ * Copyright (C) 2006 - 2008 Robert Hogan *
+ * robert@roberthogan.net *
+ * *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <qcstring.h>
+#include <qsocket.h>
+#include <qdatetime.h>
+#include <qbitarray.h>
+
+#include <stdlib.h>
+#include <math.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <kinstance.h>
+#include <kglobal.h>
+#include <kstandarddirs.h>
+#include <klocale.h>
+#include <kurl.h>
+#include <ksock.h>
+#include <dcopref.h>
+#include <dcopclient.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <krun.h>
+#include <kprocio.h>
+
+#include "torioslave.h"
+
+using namespace KIO;
+
+
+kio_torProtocol::kio_torProtocol(const QCString &pool_socket, const QCString &app_socket)
+ : SlaveBase("kio_tor", pool_socket, app_socket)
+{
+}
+
+
+kio_torProtocol::~kio_torProtocol()
+{
+}
+
+
+void kio_torProtocol::get(const KURL& url )
+{
+
+ QString wait;
+ QByteArray output;
+
+ QTextStream os( output, IO_WriteOnly );
+ os.setEncoding( QTextStream::Latin1 ); // In fast ASCII
+
+ QString cleanedurl = url.prettyURL().replace("tor://","");
+ cleanedurl = cleanedurl.replace("tor:/","");
+ cleanedurl = cleanedurl.replace("tor:","");
+ cleanedurl = cleanedurl.replace(" ","");
+ bool cantdo = false;
+
+ if (cleanedurl.contains(".txt"))
+ cantdo = true;
+
+ if (cleanedurl.contains("://") && (cleanedurl.left(4) != "http"))
+ cantdo = true;
+
+ if (cantdo){
+
+ os << QString("<html><head><title>Tor</title></head><body>%1 is not a valid URL for this feature. Websites only I'm afraid. And no file extensions either!</body></html>").arg(cleanedurl);
+
+ data( output );
+ finished();
+ return;
+ }
+
+ if ((cleanedurl.left(7) != "http://") && (cleanedurl.left(8) != "https://"))
+ cleanedurl.prepend("http://");
+
+ bool m_torkrunning = false;
+ bool anonymized = false;
+
+ DCOPClient* p_dcopServer= new DCOPClient();
+ p_dcopServer->attach ();
+
+ if (p_dcopServer->isApplicationRegistered ("tork")){
+ m_torkrunning = true;
+ DCOPRef tork( "tork", "DCOPTork" );
+ anonymized = tork.call( "getKDESetting" );
+ }
+
+
+
+ if (m_torkrunning){
+ DCOPRef("tork*", "DCOPTork").send("startEverything");
+ if (!anonymized)
+ DCOPRef("tork*", "DCOPTork").send("toggleKDESetting");
+ wait = "3";
+ }else{
+ KProcIO *whichproc = new KProcIO();
+ whichproc->setUseShell(TRUE);
+ QString whichCommand="tork --toggleKDE";
+
+ *whichproc<<whichCommand;
+
+ whichproc->start(KProcIO::NotifyOnExit,TRUE);
+
+ //KRun::runCommand( "tork --toggleKDE");
+ wait = "10";
+ }
+
+
+ os << QString("<html><head><title>Tor</title><META HTTP-EQUIV='Refresh' CONTENT='%1; URL=%2'></head><body>Will load %3 anonymously in a moment.</body></html>").arg(wait).arg(cleanedurl).arg(cleanedurl);
+
+ data( output );
+ finished();
+
+}
+
+
+void kio_torProtocol::mimetype(const KURL & /*url*/)
+{
+ mimeType("text/html");
+ finished();
+}
+
+
+extern "C"
+{
+ int kdemain(int argc, char **argv)
+ {
+ KInstance instance( "kio_tor" );
+
+ kdDebug(7101) << "*** Starting kio_tor " << endl;
+
+ if (argc != 4) {
+ kdDebug(7101) << "Usage: kio_tor protocol domain-socket1 domain-socket2" << endl;
+ exit(-1);
+ }
+
+ kio_torProtocol slave(argv[2], argv[3]);
+ slave.dispatchLoop();
+
+ kdDebug(7101) << "*** kio_tor Done" << endl;
+ return 0;
+ }
+}
diff --git a/src/tor_ioslave/torioslave.h b/src/tor_ioslave/torioslave.h
new file mode 100644
index 0000000..05e90ca
--- /dev/null
+++ b/src/tor_ioslave/torioslave.h
@@ -0,0 +1,43 @@
+/***************************************************************************
+** $Id: torioslave.h,v 1.3 2008/07/31 19:56:29 hoganrobert Exp $
+ * Copyright (C) 2006 - 2008 Robert Hogan *
+ * robert@roberthogan.net *
+ * *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef _tor_H_
+#define _tor_H_
+
+#include <qstring.h>
+#include <qcstring.h>
+
+#include <kurl.h>
+#include <kio/global.h>
+#include <kio/slavebase.h>
+
+class QCString;
+
+class kio_torProtocol : public KIO::SlaveBase
+{
+public:
+ kio_torProtocol(const QCString &pool_socket, const QCString &app_socket);
+ virtual ~kio_torProtocol();
+ virtual void mimetype(const KURL& url);
+ virtual void get(const KURL& url);
+};
+
+#endif
diff --git a/src/tor_ioslave/torioslave.lsm b/src/tor_ioslave/torioslave.lsm
new file mode 100644
index 0000000..8734d50
--- /dev/null
+++ b/src/tor_ioslave/torioslave.lsm
@@ -0,0 +1,16 @@
+Begin3
+Title: torioslave -- Some description
+Version: 0.1
+Entered-date:
+Description:
+Keywords: KDE Qt
+Author: Robert Hogan <robert@roberthogan.net>
+Maintained-by: Robert Hogan <robert@roberthogan.net>
+Home-page:
+Alternate-site:
+Primary-site: ftp://ftp.kde.org/pub/kde/unstable/apps/utils
+ xxxxxx torioslave-0.1.tar.gz
+ xxx torioslave-0.1.lsm
+Platform: Linux. Needs KDE
+Copying-policy: GPL
+End
diff --git a/src/tor_ioslave/torioslave.protocol b/src/tor_ioslave/torioslave.protocol
new file mode 100644
index 0000000..efb6111
--- /dev/null
+++ b/src/tor_ioslave/torioslave.protocol
@@ -0,0 +1,29 @@
+[Protocol]
+exec=kio_torioslave
+protocol=tor
+input=none
+output=stream
+reading=true
+defaultMimetype=text/html
+Icon=tork_tor
+Description=A kioslave for tor
+Description[da]=En kioslave til tor
+Description[de]=Ein Ein-/Ausgabemodul für tor
+Description[es]=Un kioslave para tor
+Description[et]=tor IO-moodul
+Description[fr]=Un module d'entrée / sortie pour tor
+Description[hu]=tor-támogató KIOslave
+Description[it]=Un kioslave per tor
+Description[nl]=Kioslave voor tor
+Description[pl]=kioslave dla tor
+Description[pt]=Um 'kioslave' para tor
+Description[pt_BR]=Um kioslave para tor
+Description[ru]=Обработчик ввода-вывода для tor
+Description[sl]=kioslave za tor
+Description[sr]=KIOSlave за tor
+Description[sr@Latn]=KIOSlave za tor
+Description[sv]=En I/O-slav för tor
+Description[tr]=tor için bir kioslave
+Description[uk]=Підлеглий В/В (kioslave) для tor
+Description[xx]=xxA kioslave for torxx
+Description[zh_CN]=tor 的 kioslave