kio Library API Documentation

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 #include <kdemacros.h>
00030 
00031 #include <kio/global.h>
00032 #include <kio/authinfo.h>
00033 #include <kdatastream.h>
00034 
00035 namespace KIO {
00036 
00037 class Connection;
00038 // better there is one ...
00039 class SlaveInterfacePrivate;
00040 
00041   // Definition of enum Command has been moved to global.h
00042 
00046  enum Info {
00047    INF_TOTAL_SIZE = 10,
00048    INF_PROCESSED_SIZE = 11,
00049    INF_SPEED,
00050    INF_REDIRECTION = 20,
00051    INF_MIME_TYPE = 21,
00052    INF_ERROR_PAGE = 22,
00053    INF_WARNING = 23,
00054    INF_GETTING_FILE, // Deprecated
00055    INF_NEED_PASSWD = 25,
00056    INF_INFOMESSAGE,
00057    INF_META_DATA,
00058    INF_NETWORK_STATUS,
00059    INF_MESSAGEBOX
00060    // add new ones here once a release is done, to avoid breaking binary compatibility
00061  };
00062 
00066  enum Message {
00067    MSG_DATA = 100,
00068    MSG_DATA_REQ,
00069    MSG_ERROR,
00070    MSG_CONNECTED,
00071    MSG_FINISHED,
00072    MSG_STAT_ENTRY,
00073    MSG_LIST_ENTRIES,
00074    MSG_RENAMED, // unused
00075    MSG_RESUME,
00076    MSG_SLAVE_STATUS,
00077    MSG_SLAVE_ACK,
00078    MSG_NET_REQUEST,
00079    MSG_NET_DROP,
00080    MSG_NEED_SUBURL_DATA,
00081    MSG_CANRESUME,
00082    MSG_AUTH_KEY, // deprecated.
00083    MSG_DEL_AUTH_KEY // deprecated.
00084    // add new ones here once a release is done, to avoid breaking binary compatibility
00085  };
00086 
00094 class SlaveInterface : public QObject
00095 {
00096     Q_OBJECT
00097 
00098 public:
00099     SlaveInterface( Connection *connection );
00100     virtual ~SlaveInterface();
00101 
00102     void setConnection( Connection* connection ) { m_pConnection = connection; }
00103     Connection *connection() const { return m_pConnection; }
00104 
00105     void setProgressId( int id ) { m_progressId = id; }
00106     int progressId() const { return m_progressId; }
00107 
00108     // Send our answer to the MSG_RESUME (canResume) request
00109     // (to tell the "put" job whether to resume or not)
00110     void sendResumeAnswer( bool resume );
00111 
00112     void setOffset( KIO::filesize_t offset );
00113     KIO::filesize_t offset() const;
00114 
00115 signals:
00117     // Messages sent by the slave
00119 
00120     void data( const QByteArray & );
00121     void dataReq( );
00122     void error( int , const QString & );
00123     void connected();
00124     void finished();
00125     void slaveStatus(pid_t, const QCString &, const QString &, bool);
00126     void listEntries( const KIO::UDSEntryList& );
00127     void statEntry( const KIO::UDSEntry& );
00128     void needSubURLData();
00129     void needProgressId();
00130 
00131     void canResume( KIO::filesize_t ) ;
00132 
00134     // Info sent by the slave
00136     void metaData( const KIO::MetaData & );
00137     void totalSize( KIO::filesize_t ) ;
00138     void processedSize( KIO::filesize_t ) ;
00139     void redirection( const KURL& ) ;
00140 
00141     void speed( unsigned long ) ;
00142     void errorPage() ;
00143     void mimeType( const QString & ) ;
00144     void warning( const QString & ) ;
00145     void infoMessage( const QString & ) ;
00146     void connectFinished();
00147 
00151     void authorizationKey( const QCString&, const QCString&, bool );
00152 
00156     void delAuthorization( const QCString& grpkey );
00157 
00158 protected:
00160     // Dispatching
00162 
00163     virtual bool dispatch();
00164     virtual bool dispatch( int _cmd, const QByteArray &data );
00165 
00205     void openPassDlg( KIO::AuthInfo& info );
00206 
00210     void openPassDlg( const QString& prompt, const QString& user,
00211                       const QString& caption, const QString& comment,
00212                       const QString& label, bool readOnly ) KDE_DEPRECATED;
00213 
00217     void openPassDlg( const QString& prompt, const QString& user, bool readOnly ) KDE_DEPRECATED;
00218 
00219     void messageBox( int type, const QString &text, const QString &caption,
00220                      const QString &buttonYes, const QString &buttonNo );
00221 
00222     // I need to identify the slaves
00223     void requestNetwork( const QString &, const QString &);
00224     void dropNetwork( const QString &, const QString &);
00225 
00230     static void sigpipe_handler(int);
00231 
00232 protected slots:
00233     void calcSpeed();
00234 
00235 protected:
00236     Connection * m_pConnection;
00237 
00238 private:
00239     int m_progressId;
00240 protected:
00241     virtual void virtual_hook( int id, void* data );
00242 private:
00243     SlaveInterfacePrivate *d;
00244 };
00245 
00246 }
00247 
00248 inline QDataStream &operator >>(QDataStream &s, KIO::UDSAtom &a )
00249 {
00250     long l;
00251     s >> a.m_uds;
00252 
00253     if ( a.m_uds & KIO::UDS_LONG ) {
00254         s >> l;
00255         a.m_long = l;
00256         a.m_str = QString::null;
00257     } else if ( a.m_uds & KIO::UDS_STRING ) {
00258         s >> a.m_str;
00259         a.m_long = 0;
00260     } else {} // DIE!
00261     //    assert( 0 );
00262 
00263     return s;
00264 }
00265 
00266 inline QDataStream &operator <<(QDataStream &s, const KIO::UDSAtom &a )
00267 {
00268     s << a.m_uds;
00269 
00270     if ( a.m_uds & KIO::UDS_LONG )
00271         s << (long) a.m_long;
00272     else if ( a.m_uds & KIO::UDS_STRING )
00273         s << a.m_str;
00274     else {} // DIE!
00275     //    assert( 0 );
00276 
00277     return s;
00278 }
00279 
00280 QDataStream &operator <<(QDataStream &s, const KIO::UDSEntry &e );
00281 QDataStream &operator >>(QDataStream &s, KIO::UDSEntry &e );
00282 
00283 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 14 09:17:15 2006 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003