• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kio

slave.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 /*
00003  *  This file is part of the KDE libraries
00004  *  Copyright (c) 2000 Waldo Bastian <bastian@kde.org>
00005  *                2000 Stephan Kulow <coolo@kde.org>
00006  *
00007  *  This library is free software; you can redistribute it and/or
00008  *  modify it under the terms of the GNU Library General Public
00009  *  License version 2 as published by the Free Software Foundation.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Library General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Library General Public License
00017  *  along with this library; see the file COPYING.LIB.  If not, write to
00018  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  *  Boston, MA 02110-1301, USA.
00020  **/
00021 
00022 #ifndef KIO_SLAVE_H
00023 #define KIO_SLAVE_H
00024 
00025 #include <time.h>
00026 #include <unistd.h>
00027 
00028 #include <qobject.h>
00029 
00030 #include <kurl.h>
00031 
00032 #include "kio/slaveinterface.h"
00033 #include "kio/connection.h"
00034 
00035 class KServerSocket;
00036 class KSocket;
00037 
00038 namespace KIO {
00039 
00044     class KIO_EXPORT Slave : public KIO::SlaveInterface
00045     {
00046     Q_OBJECT
00047 
00048     protected:
00055     Slave(bool derived, KServerSocket *unixdomain, const QString &protocol,
00056         const QString &socketname); // TODO(BIC): Remove in KDE 4
00057 
00058     public:
00059     Slave(KServerSocket *unixdomain,
00060           const QString &protocol, const QString &socketname);
00061 
00062         virtual ~Slave();
00063 
00064     void setPID(pid_t);
00065 
00066         int slave_pid() { return m_pid; }
00067 
00071     void kill();
00072 
00076         bool isAlive() { return !dead; }
00077 
00085         void setHost( const QString &host, int port,
00086                       const QString &user, const QString &passwd); // TODO(BIC): make virtual
00087 
00091         void resetHost();
00092 
00096         void setConfig(const MetaData &config); // TODO(BIC): make virtual
00097 
00103         QString protocol() { return m_protocol; }
00104 
00105         void setProtocol(const QString & protocol);
00118         QString slaveProtocol() { return m_slaveProtocol; }
00119 
00123         QString host() { return m_host; }
00124 
00128         int port() { return m_port; }
00129 
00133         QString user() { return m_user; }
00134 
00138         QString passwd() { return m_passwd; }
00139 
00151     static Slave* createSlave( const QString &protocol, const KURL& url, int& error, QString& error_text );
00152 
00153         static Slave* holdSlave( const QString &protocol, const KURL& url );
00154 
00155     // == communication with connected kioslave ==
00156     // whenever possible prefer these methods over the respective
00157     // methods in connection()
00161         void suspend();     // TODO(BIC): make virtual
00165         void resume();      // TODO(BIC): make virtual
00171         bool suspended();   // TODO(BIC): make virtual
00178         void send(int cmd, const QByteArray &data = QByteArray());// TODO(BIC): make virtual
00179     // == end communication with connected kioslave ==
00180 
00184     void hold(const KURL &url); // TODO(BIC): make virtual
00185 
00189     time_t idleTime();
00190 
00194     void setIdle();
00195 
00196         /*
00197          * @returns Whether the slave is connected
00198          * (Connection oriented slaves only)
00199          */
00200         bool isConnected() { return contacted; }
00201         void setConnected(bool c) { contacted = c; }
00202 
00207         KDE_DEPRECATED Connection *connection() { return &slaveconn; }  // TODO(BIC): remove before KDE 4
00208 
00209         void ref() { m_refCount++; }
00210         void deref() { m_refCount--; if (!m_refCount) delete this; }
00211 
00212     public slots:
00213         void accept(KSocket *socket);
00214     void gotInput();
00215     void timeout();
00216     signals:
00217         void slaveDied(KIO::Slave *slave);
00218 
00219     protected:
00220         void unlinkSocket();
00221 
00222     private:
00223         QString m_protocol;
00224         QString m_slaveProtocol;
00225         QString m_host;
00226         int m_port;
00227         QString m_user;
00228         QString m_passwd;
00229     KServerSocket *serv;
00230     QString m_socket;
00231     pid_t m_pid;
00232     bool contacted;
00233     bool dead;
00234     time_t contact_started;
00235     time_t idle_since;
00236     KIO::Connection slaveconn;
00237     int m_refCount;
00238     protected:
00239     virtual void virtual_hook( int id, void* data );
00240     // grant SlaveInterface all IDs < 0x200
00241     enum { VIRTUAL_SUSPEND = 0x200, VIRTUAL_RESUME, VIRTUAL_SEND,
00242         VIRTUAL_HOLD, VIRTUAL_SUSPENDED,
00243         VIRTUAL_SET_HOST, VIRTUAL_SET_CONFIG };
00244     struct SendParams {
00245       int cmd;
00246       const QByteArray *arr;
00247     };
00248     struct HoldParams {
00249       const KURL *url;
00250     };
00251     struct SuspendedParams {
00252       bool retval;
00253     };
00254     struct SetHostParams {
00255       const QString *host;
00256       int port;
00257       const QString *user;
00258       const QString *passwd;
00259     };
00260     struct SetConfigParams {
00261       const MetaData *config;
00262     };
00263     private:
00264     class SlavePrivate* d;
00265     };
00266 
00267 }
00268 
00269 #endif

kio

Skip menu "kio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal