# kio Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# slaveinterface.h

    00001 /* This file is part of the KDE project
    00002    Copyright (C) 2000 David Faure <faure@kde.org>
    00003
    00004    This library is free software; you can redistribute it and/or
    00005    modify it under the terms of the GNU Library General Public
    00006    License as published by the Free Software Foundation; either
    00007    version 2 of the License, or (at your option) any later version.
    00008
    00009    This library is distributed in the hope that it will be useful,
    00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012    Library General Public License for more details.
    00013
    00014    You should have received a copy of the GNU Library General Public License
    00015    along with this library; see the file COPYING.LIB.  If not, write to
    00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017    Boston, MA 02111-1307, USA.
    00018 */
    00019
    00020 #ifndef __kio_slaveinterface_h
    00021 #define __kio_slaveinterface_h
    00022
    00023 #include <unistd.h>
    00024 #include <sys/types.h>
    00025
    00026 #include <qobject.h>
    00027
    00028 #include <kurl.h>
    00029
    00030 #include <kio/global.h>
    00031 #include <kio/authinfo.h>
    00032 #include <kdatastream.h>
    00033
    00034 namespace KIO {
    00035
    00036 class Connection;
    00037 // better there is one ...
    00038 class SlaveInterfacePrivate;
    00039
    00043  enum Command {
    00044    CMD_HOST = '0',
    00045    CMD_CONNECT = '1',
    00046    CMD_DISCONNECT = '2',
    00047    CMD_SLAVE_STATUS = '3',
    00048    CMD_SLAVE_CONNECT = '4',
    00049    CMD_SLAVE_HOLD = '5',
    00050    CMD_NONE = 'A', // 65
    00051    CMD_TESTDIR = 'B', // 66
    00052    CMD_GET = 'C', // 67
    00053    CMD_PUT = 'D', // 68
    00054    CMD_STAT = 'E', // 69
    00055    CMD_MIMETYPE = 'F', // 70
    00056    CMD_LISTDIR = 'G', // 71
    00057    CMD_MKDIR = 'H', // 72
    00058    CMD_RENAME = 'I', // 73
    00059    CMD_COPY = 'J', // 74
    00060    CMD_DEL = 'K', // 75
    00061    CMD_CHMOD = 'L', // 76
    00062    CMD_SPECIAL = 'M', // 77
    00063    CMD_USERPASS = 'N', // 78
    00064    CMD_REPARSECONFIGURATION = 'O', // 79
    00065    CMD_META_DATA = 'P', // 80
    00066    CMD_SYMLINK = 'Q', // 81
    00067    CMD_SUBURL = 'R', // 82  Inform the slave about the url it is streaming on.
    00068    CMD_MESSAGEBOXANSWER = 'S', // 83
    00069    CMD_RESUMEANSWER = 'T', // 84
    00070    CMD_CONFIG = 'U', // 85
    00071    CMD_MULTI_GET = 'V' // 86
    00072    // Add new ones here once a release is done, to avoid breaking binary compatibility.
    00073    // Note that protocol-specific commands shouldn't be added here, but should use special.
    00074  };
    00075
    00079  enum Info {
    00080    INF_TOTAL_SIZE = 10,
    00081    INF_PROCESSED_SIZE = 11,
    00082    INF_SPEED,
    00083    INF_REDIRECTION = 20,
    00084    INF_MIME_TYPE = 21,
    00085    INF_ERROR_PAGE = 22,
    00086    INF_WARNING = 23,
    00087    INF_GETTING_FILE, // Deprecated
    00088    INF_NEED_PASSWD = 25,
    00089    INF_INFOMESSAGE,
    00090    INF_META_DATA,
    00091    INF_NETWORK_STATUS,
    00092    INF_MESSAGEBOX
    00093    // add new ones here once a release is done, to avoid breaking binary compatibility
    00094  };
    00095
    00099  enum Message {
    00100    MSG_DATA = 100,
    00101    MSG_DATA_REQ,
    00102    MSG_ERROR,
    00103    MSG_CONNECTED,
    00104    MSG_FINISHED,
    00105    MSG_STAT_ENTRY,
    00106    MSG_LIST_ENTRIES,
    00107    MSG_RENAMED, // unused
    00108    MSG_RESUME,
    00109    MSG_SLAVE_STATUS,
    00110    MSG_SLAVE_ACK,
    00111    MSG_NET_REQUEST,
    00112    MSG_NET_DROP,
    00113    MSG_NEED_SUBURL_DATA,
    00114    MSG_CANRESUME,
    00115    MSG_AUTH_KEY,
    00116    MSG_DEL_AUTH_KEY
    00117    // add new ones here once a release is done, to avoid breaking binary compatibility
    00118  };
    00119
    00127 class SlaveInterface : public QObject
    00128 {
    00129     Q_OBJECT
    00130
    00131 public:
    00132     SlaveInterface( Connection *connection );
    00133     virtual ~SlaveInterface();
    00134
    00135     void setConnection( Connection* connection ) { m_pConnection = connection; }
    00136     Connection *connection() const { return m_pConnection; }
    00137
    00138     void setProgressId( int id ) { m_progressId = id; }
    00139     int progressId() const { return m_progressId; }
    00140
    00141     // Send our answer to the MSG_RESUME (canResume) request
    00142     // (to tell the "put" job whether to resume or not)
    00143     void sendResumeAnswer( bool resume );
    00144
    00145     void setOffset( KIO::filesize_t offset );
    00146     KIO::filesize_t offset() const;
    00147
    00148 signals:
    00150     // Messages sent by the slave
    00152
    00153     void data( const QByteArray & );
    00154     void dataReq( );
    00155     void error( int , const QString & );
    00156     void connected();
    00157     void finished();
    00158     void slaveStatus(pid_t, const QCString &, const QString &, bool);
    00159     void listEntries( const KIO::UDSEntryList& );
    00160     void statEntry( const KIO::UDSEntry& );
    00161     void needSubURLData();
    00162     void needProgressId();
    00163
    00164     void canResume( KIO::filesize_t ) ;
    00165
    00167     // Info sent by the slave
    00169     void metaData( const KIO::MetaData & );
    00170     void totalSize( KIO::filesize_t ) ;
    00171     void processedSize( KIO::filesize_t ) ;
    00172     void redirection( const KURL& ) ;
    00173
    00174     void speed( unsigned long ) ;
    00175     void errorPage() ;
    00176     void mimeType( const QString & ) ;
    00177     void warning( const QString & ) ;
    00178     void infoMessage( const QString & ) ;
    00179     void connectFinished();
    00180
    00190     void authorizationKey( const QCString&, const QCString&, bool );
    00191
    00198     void delAuthorization( const QCString& grpkey );
    00199
    00200 protected:
    00202     // Dispatching
    00204
    00205     virtual bool dispatch();
    00206     virtual bool dispatch( int _cmd, const QByteArray &data );
    00207
    00247     void openPassDlg( KIO::AuthInfo& info );
    00248
    00254     void openPassDlg( const QString& prompt, const QString& user,
    00255                       const QString& caption, const QString& comment,
    00256                       const QString& label, bool readOnly );
    00257
    00263     void openPassDlg( const QString& prompt, const QString& user, bool readOnly );
    00264
    00265     void messageBox( int type, const QString &text, const QString &caption,
    00266                      const QString &buttonYes, const QString &buttonNo );
    00267
    00268     // I need to identify the slaves
    00269     void requestNetwork( const QString &, const QString &);
    00270     void dropNetwork( const QString &, const QString &);
    00271
    00275     static void sigpipe_handler(int);
    00276
    00277 protected slots:
    00278     void calcSpeed();
    00279
    00280 protected:
    00281     Connection * m_pConnection;
    00282
    00283 private:
    00284     int m_progressId;
    00285 protected:
    00286     virtual void virtual_hook( int id, void* data );
    00287 private:
    00288     SlaveInterfacePrivate *d;
    00289 };
    00290
    00291 }
    00292
    00293 inline QDataStream &operator >>(QDataStream &s, KIO::UDSAtom &a )
    00294 {
    00295     long l;
    00296     s >> a.m_uds;
    00297
    00298     if ( a.m_uds & KIO::UDS_LONG ) {
    00299         s >> l;
    00300         a.m_long = l;
    00301         a.m_str = QString::null;
    00302     } else if ( a.m_uds & KIO::UDS_STRING ) {
    00303         s >> a.m_str;
    00304         a.m_long = 0;
    00305     } else {} // DIE!
    00306     //    assert( 0 );
    00307
    00308     return s;
    00309 }
    00310
    00311 inline QDataStream &operator <<(QDataStream &s, const KIO::UDSAtom &a )
    00312 {
    00313     s << a.m_uds;
    00314
    00315     if ( a.m_uds & KIO::UDS_LONG )
    00316         s << (long) a.m_long;
    00317     else if ( a.m_uds & KIO::UDS_STRING )
    00318         s << a.m_str;
    00319     else {} // DIE!
    00320     //    assert( 0 );
    00321
    00322     return s;
    00323 }
    00324
    00325 QDataStream &operator <<(QDataStream &s, const KIO::UDSEntry &e );
    00326 QDataStream &operator >>(QDataStream &s, KIO::UDSEntry &e );
    00327
    00328 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:14:40 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001