/*************************************************************************** kmd.cpp - description ------------------- begin : Tue Jan 15 00:49:05 MST 2002 copyright : (C) 2002 by Simon R email : mail@srobins.org ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include "kmd.h" using namespace KIO; extern "C"{ int kdemain( int argc, char **argv ){ KInstance instance( "kio_kmd" ); if (argc != 4){ exit(-1); } kio_kmdProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); //QApplication::enter_loop(); return 0; } } kio_kmdProtocol::kio_kmdProtocol(const QCString &pool_socket, const QCString &app_socket) : QObject(), SlaveBase("kio_kmd", pool_socket, app_socket) { kdDebug() << "kio_kmdProtocol::kio_kmdProtocol()" << endl; } /* ---------------------------------------------------------------------------------- */ kio_kmdProtocol::~kio_kmdProtocol() { } /* ---------------------------------------------------------------------------------- */ void kio_kmdProtocol::get(const KURL& url ) { qInitNetworkProtocols (); kdDebug() << "kio_urn::get(const KURL& url)" << endl ; kdDebug() << "myURL: " << url.prettyURL() << endl; mimeType("text/html"); kdDebug() << "0" << endl; http = new QHttp(); connect(http, SIGNAL(stateChanged(int)), this, SLOT(slotStateChanged(int))); kdDebug() << "1" << endl; connect(http, SIGNAL(readyRead(const QHttpResponseHeader &)), this, SLOT(slotReadyRead())); connect(http, SIGNAL(requestStarted(int)), this, SLOT(slotRequestStarted(int))); kdDebug() << "2" << endl; http->setHost("www.trolltech.com"); requestNr = http->get("/index.html"); kdDebug() << "request id: " << requestNr << endl; } void kio_kmdProtocol::mimetype(const KURL & /*url*/) { mimeType("text/html"); finished(); } /* --------------------------------------------------------------------------- */ void kio_kmdProtocol::slotStateChanged(int state) { kdDebug() << "kio_urn -> state " << state << endl; } void kio_kmdProtocol::slotReadyRead() { kdDebug() << "kio_urn -> data received" << endl; if(http->bytesAvailable() > 0) data(http->readAll()); } void kio_kmdProtocol::slotRequestStarted(int req) { kdDebug() << "kio_urn -> reqstart " << req << endl; }