kio Library API Documentation

slavebase.h

00001 /* 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 __slavebase_h 00021 #define __slavebase_h 00022 00023 #include <kurl.h> 00024 #include <kconfigbase.h> 00025 #include <kio/global.h> 00026 #include <kio/authinfo.h> 00027 00028 class DCOPClient; 00029 00030 namespace KIO { 00031 00032 class Connection; 00033 class SlaveBasePrivate; 00034 00044 class SlaveBase 00045 { 00046 public: 00047 SlaveBase( const QCString &protocol, const QCString &pool_socket, const QCString &app_socket); 00048 virtual ~SlaveBase(); 00049 00054 void exit(); 00055 00059 void dispatchLoop(); 00060 00064 void setConnection( Connection* connection ) { m_pConnection = connection; } 00068 Connection *connection() const { return m_pConnection; } 00069 00070 00072 // Message Signals to send to the job 00074 00083 void data( const QByteArray &data ); 00084 00089 void dataReq( ); 00090 00108 void error( int _errid, const QString &_text ); 00109 00113 void connected(); 00114 00119 void finished(); 00120 00124 void needSubURLData(); 00125 00132 void slaveStatus(const QString &host, bool connected); 00133 00140 void statEntry( const UDSEntry& _entry ); 00141 00146 void listEntries( const UDSEntryList& _entry ); 00147 00155 bool canResume( KIO::filesize_t offset ); 00156 00157 /* 00158 * Call this at the beginning of get(), if the "resume" metadata was set 00159 * and resuming is implemented by this protocol. 00160 */ 00161 void canResume(); 00162 00164 // Info Signals to send to the job 00166 00172 void totalSize( KIO::filesize_t _bytes ); 00178 void processedSize( KIO::filesize_t _bytes ); 00179 00191 void processedPercent( float percent ); 00192 00198 void speed( unsigned long _bytes_per_second ); 00199 00204 void redirection( const KURL &_url ); 00205 00211 void errorPage(); 00212 00217 void mimeType( const QString &_type ); 00218 00222 void warning( const QString &msg ); 00223 00228 void infoMessage( const QString &msg ); 00229 00230 enum MessageBoxType { QuestionYesNo = 1, WarningYesNo = 2, WarningContinueCancel = 3, WarningYesNoCancel = 4, Information = 5, SSLMessageBox = 6 }; 00231 00247 int messageBox( MessageBoxType type, const QString &text, 00248 const QString &caption = QString::null, 00249 const QString &buttonYes = QString::null, 00250 const QString &buttonNo = QString::null ); 00251 00256 void setMetaData(const QString &key, const QString &value); 00257 00263 bool hasMetaData(const QString &key) const; 00264 00269 QString metaData(const QString &key) const; 00270 00276 bool hasMetaData(const QString &key); 00277 00282 QString metaData(const QString &key); 00283 00291 KConfigBase* config(); 00292 00294 // Commands sent by the job, the slave has to 00295 // override what it wants to implement 00297 00309 virtual void setHost(const QString& host, int port, const QString& user, const QString& pass); 00310 00314 virtual void setSubURL(const KURL&url); 00315 00325 virtual void openConnection(); 00326 00335 virtual void closeConnection(); 00336 00343 virtual void get( const KURL& url ); 00344 00354 virtual void put( const KURL& url, int permissions, bool overwrite, bool resume ); 00355 00361 virtual void stat( const KURL& url ); 00362 00375 virtual void mimetype( const KURL& url ); 00376 00384 virtual void listDir( const KURL& url ); 00385 00393 virtual void mkdir( const KURL&url, int permissions ); 00394 00403 virtual void rename( const KURL& src, const KURL& dest, bool overwrite ); 00404 00412 virtual void symlink( const QString& target, const KURL& dest, bool overwrite ); 00413 00418 virtual void chmod( const KURL& url, int permissions ); 00419 00430 virtual void copy( const KURL &src, const KURL &dest, int permissions, bool overwrite ); 00431 00438 virtual void del( const KURL &url, bool isfile); 00439 00448 virtual void special( const QByteArray & data ); 00449 00457 virtual void multiGet( const QByteArray & data ); 00458 00463 virtual void slave_status(); 00464 00469 virtual void reparseConfiguration(); 00470 00471 00475 int connectTimeout(); 00476 00480 int proxyConnectTimeout(); 00481 00486 int responseTimeout(); 00487 00492 int readTimeout(); 00493 00508 void setTimeoutSpecialCommand(int timeout, const QByteArray &data=QByteArray()); 00509 00513 static void sigsegv_handler(int); 00517 static void sigpipe_handler(int); 00518 00520 // Dispatching (internal) 00522 00526 virtual bool dispatch(); 00530 virtual void dispatch( int command, const QByteArray &data ); 00531 00540 int readData( QByteArray &buffer ); 00541 00552 void listEntry( const UDSEntry& _entry, bool ready); 00553 00558 void connectSlave(const QString& path); 00559 void disconnectSlave(); 00560 00605 bool openPassDlg( KIO::AuthInfo& info, const QString &errorMsg ); 00606 00611 bool openPassDlg( KIO::AuthInfo& info ); 00612 00640 bool checkCachedAuthentication( AuthInfo& info ); 00641 00648 bool cacheAuthentication( const AuthInfo& info ); 00649 00654 bool pingCacheDaemon() const; 00655 00662 QString createAuthCacheKey( const KURL& url ); 00663 00671 void sendAuthenticationKey( const QCString& gKey, const QCString& key, bool keep ); 00672 00681 void delCachedAuthentication( const QString& key ); 00682 00687 void setMultipleAuthCaching( bool ) {}; 00688 00693 bool multipleAuthCaching() const { return false; } 00694 00713 bool requestNetwork(const QString& host = QString::null); 00714 00728 void dropNetwork(const QString& host = QString::null); 00729 00734 DCOPClient *dcopClient(); 00735 00740 int waitForAnswer( int expected1, int expected2, QByteArray & data, int * pCmd = 0 ); 00741 00745 void sendMetaData(); 00746 00750 QCString mProtocol; 00751 00752 Connection * m_pConnection; 00753 00754 MetaData mOutgoingMetaData; 00755 MetaData mIncomingMetaData; 00756 00763 bool wasKilled() const; 00764 00769 void setKillFlag(); 00770 00771 protected: 00772 UDSEntryList pendingListEntries; 00773 uint listEntryCurrentSize; 00774 long listEntry_sec, listEntry_usec; 00775 Connection *appconn; 00776 QString mPoolSocket; 00777 QString mAppSocket; 00778 bool mConnectedToApp; 00779 static long s_seqNr; 00780 virtual void virtual_hook( int id, void* data ); 00781 00782 private: 00783 SlaveBasePrivate *d; 00784 }; 00785 00786 } 00787 00788 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Aug 30 22:54:44 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003