summaryrefslogtreecommitdiffstats
path: root/languages/csharp/csharpdoc.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/csharp/csharpdoc.cpp
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'languages/csharp/csharpdoc.cpp')
-rw-r--r--languages/csharp/csharpdoc.cpp133
1 files changed, 133 insertions, 0 deletions
diff --git a/languages/csharp/csharpdoc.cpp b/languages/csharp/csharpdoc.cpp
new file mode 100644
index 00000000..8755be2b
--- /dev/null
+++ b/languages/csharp/csharpdoc.cpp
@@ -0,0 +1,133 @@
+#include "csharpdoc.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <qtextstream.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <kinstance.h>
+#include <kprocess.h>
+#include <kdeversion.h>
+#include <kglobal.h>
+
+using namespace KIO;
+
+
+CSharpdocProtocol::CSharpdocProtocol(const QCString &pool, const QCString &app)
+ : SlaveBase("csharpdoc", pool, app)
+{}
+
+
+CSharpdocProtocol::~CSharpdocProtocol()
+{}
+
+
+void CSharpdocProtocol::get(const KURL& url)
+{
+ QStringList l = QStringList::split('/', url.path());
+
+ mimeType("text/html");
+
+ bool plain = false;
+ QString cmd = "csharpdoc ";
+ if (l[0] == "functions") {
+ plain = true;
+ cmd += "-t -f ";
+ cmd += KProcess::quote(l[1]);
+ } else if (l[0] == "faq") {
+ cmd += "-u -q ";
+ cmd += KProcess::quote(l[1]);
+ cmd += " | pod2html";
+ } else {
+ QCString errstr(i18n("The only existing directories are functions and faq.").local8Bit());
+ data(errstr);
+ finished();
+ return;
+ }
+
+ kdDebug() << "Command: " << cmd << endl;
+
+ if (plain)
+ data(QCString("<blockquote>"));
+
+ FILE *fd = popen(cmd.local8Bit().data(), "r");
+ char buffer[4090];
+ QByteArray array;
+
+ while (!feof(fd)) {
+ int n = fread(buffer, 1, 2048, fd);
+ if (n == -1) {
+ pclose(fd);
+ return;
+ }
+ array.setRawData(buffer, n);
+ data(array);
+ array.resetRawData(buffer, n);
+ }
+
+ pclose(fd);
+
+ if (plain)
+ data(QCString("</blockquote>"));
+
+ finished();
+}
+
+
+void CSharpdocProtocol::mimetype(const KURL &url)
+{
+ QStringList l = QStringList::split('/', url.path());
+ mimeType((l[0] == "faq")? "text/html" : "text/plain");
+ finished();
+}
+
+
+QCString CSharpdocProtocol::errorMessage()
+{
+ return QCString( "<html><body bgcolor=\"#FFFFFF\">" + i18n("Error in csharpdoc").local8Bit() + "</body></html>" );
+}
+
+
+void CSharpdocProtocol::stat(const KURL &/*url*/)
+{
+ UDSAtom uds_atom;
+ uds_atom.m_uds = KIO::UDS_FILE_TYPE;
+ uds_atom.m_long = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO;
+
+ UDSEntry uds_entry;
+ uds_entry.append(uds_atom);
+
+ statEntry(uds_entry);
+ finished();
+}
+
+
+void CSharpdocProtocol::listDir(const KURL &url)
+{
+ error( KIO::ERR_CANNOT_ENTER_DIRECTORY, url.path() );
+}
+
+
+extern "C" {
+
+ int kdemain(int argc, char **argv)
+ {
+ KInstance instance( "kio_csharpdoc" );
+ KGlobal::locale()->setMainCatalogue("kdevelop");
+
+ if (argc != 4) {
+ fprintf(stderr, "Usage: kio_csharpdoc protocol domain-socket1 domain-socket2\n");
+ exit(-1);
+ }
+
+ CSharpdocProtocol slave(argv[2], argv[3]);
+ slave.dispatchLoop();
+
+ return 0;
+ }
+
+}