kio Library: slave.h Source File (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# slave.h

    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., 59 Temple Place - Suite 330,
    00019  *  Boston, MA 02111-1307, 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
    00040     // Attention developers: If you change the implementation of KIO::Slave,
    00041     // do *not* use connection() or slaveconn but the respective KIO::Slave
    00042     // accessor methods. Otherwise classes derived from Slave might break. (LS)
    00043     class KIO_EXPORT Slave : public KIO::SlaveInterface
    00044     {
    00045     Q_OBJECT
    00046
    00047     protected:
    00054     Slave(bool derived, KServerSocket *unixdomain, const QString &protocol,
    00055         const QString &socketname); // TODO(BIC): Remove in KDE 4
    00056
    00057     public:
    00058     Slave(KServerSocket *unixdomain,
    00059           const QString &protocol, const QString &socketname);
    00060
    00061         virtual ~Slave();
    00062
    00063     void setPID(pid_t);
    00064
    00065         int slave_pid() { return m_pid; }
    00066
    00070     void kill();
    00071
    00075         bool isAlive() { return !dead; }
    00076
    00084         void setHost( const QString &host, int port,
    00085                       const QString &user, const QString &passwd); // TODO(BIC): make virtual
    00086
    00090         void resetHost();
    00091
    00095         void setConfig(const MetaData &config); // TODO(BIC): make virtual
    00096
    00102         QString protocol() { return m_protocol; }
    00103
    00104         void setProtocol(const QString & protocol);
    00117         QString slaveProtocol() { return m_slaveProtocol; }
    00118
    00122         QString host() { return m_host; }
    00123
    00127         int port() { return m_port; }
    00128
    00132         QString user() { return m_user; }
    00133
    00137         QString passwd() { return m_passwd; }
    00138
    00147     static Slave* createSlave( const QString &protocol, const KURL& url, int& error, QString& error_text );
    00148
    00149         static Slave* holdSlave( const QString &protocol, const KURL& url );
    00150
    00151     // == communication with connected kioslave ==
    00152     // whenever possible prefer these methods over the respective
    00153     // methods in connection()
    00157         void suspend();     // TODO(BIC): make virtual
    00161         void resume();      // TODO(BIC): make virtual
    00167         bool suspended();   // TODO(BIC): make virtual
    00174         void send(int cmd, const QByteArray &arr = QByteArray());// TODO(BIC): make virtual
    00175     // == end communication with connected kioslave ==
    00176
    00180     void hold(const KURL &url); // TODO(BIC): make virtual
    00181
    00185     time_t idleTime();
    00186
    00190     void setIdle();
    00191
    00192         /*
    00193          * @returns Whether the slave is connected
    00194          * (Connection oriented slaves only)
    00195          */
    00196         bool isConnected() { return contacted; }
    00197         void setConnected(bool c) { contacted = c; }
    00198
    00203         KDE_DEPRECATED Connection *connection() { return &slaveconn; }  // TODO(BIC): remove before KDE 4
    00204
    00205         void ref() { m_refCount++; }
    00206         void deref() { m_refCount--; if (!m_refCount) delete this; }
    00207
    00208     public slots:
    00209         void accept(KSocket *socket);
    00210     void gotInput();
    00211     void timeout();
    00212     signals:
    00213         void slaveDied(KIO::Slave *slave);
    00214
    00215     protected:
    00216         void unlinkSocket();
    00217
    00218     private:
    00219         QString m_protocol;
    00220         QString m_slaveProtocol;
    00221         QString m_host;
    00222         int m_port;
    00223         QString m_user;
    00224         QString m_passwd;
    00225     KServerSocket *serv;
    00226     QString m_socket;
    00227     pid_t m_pid;
    00228     bool contacted;
    00229     bool dead;
    00230     time_t contact_started;
    00231     time_t idle_since;
    00232     KIO::Connection slaveconn;
    00233     int m_refCount;
    00234     protected:
    00235     virtual void virtual_hook( int id, void* data );
    00236     // grant SlaveInterface all IDs < 0x200
    00237     enum { VIRTUAL_SUSPEND = 0x200, VIRTUAL_RESUME, VIRTUAL_SEND,
    00238         VIRTUAL_HOLD, VIRTUAL_SUSPENDED,
    00239         VIRTUAL_SET_HOST, VIRTUAL_SET_CONFIG };
    00240     struct SendParams {
    00241       int cmd;
    00242       const QByteArray *arr;
    00243     };
    00244     struct HoldParams {
    00245       const KURL *url;
    00246     };
    00247     struct SuspendedParams {
    00248       bool retval;
    00249     };
    00250     struct SetHostParams {
    00251       const QString *host;
    00252       int port;
    00253       const QString *user;
    00254       const QString *passwd;
    00255     };
    00256     struct SetConfigParams {
    00257       const MetaData *config;
    00258     };
    00259     private:
    00260     class SlavePrivate* d;
    00261     };
    00262
    00263 }
    00264
    00265 #endif

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:24:07 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003