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