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 class KRemoteEncoding;
00030 
00031 namespace KIO {
00032 
00033 class Connection;
00034 class SlaveBasePrivate;
00035 
00045 class SlaveBase
00046 {
00047 public:
00048     SlaveBase( const QCString &protocol, const QCString &pool_socket, const QCString &app_socket);
00049     virtual ~SlaveBase();
00050 
00055     void exit();
00056 
00060     void dispatchLoop();
00061 
00065     void setConnection( Connection* connection ) { m_pConnection = connection; }
00069     Connection *connection() const { return m_pConnection; }
00070 
00071 
00073     // Message Signals to send to the job
00075 
00084     void data( const QByteArray &data );
00085 
00090     void dataReq( );
00091 
00109     void error( int _errid, const QString &_text );
00110 
00114     void connected();
00115 
00120     void finished();
00121 
00125     void needSubURLData();
00126 
00133     void slaveStatus(const QString &host, bool connected);
00134 
00141     void statEntry( const UDSEntry& _entry );
00142 
00147     void listEntries( const UDSEntryList& _entry );
00148 
00156     bool canResume( KIO::filesize_t offset );
00157 
00158     /*
00159      * Call this at the beginning of get(), if the "resume" metadata was set
00160      * and resuming is implemented by this protocol.
00161      */
00162     void canResume();
00163 
00165     // Info Signals to send to the job
00167 
00173     void totalSize( KIO::filesize_t _bytes );
00179     void processedSize( KIO::filesize_t _bytes );
00180 
00192     void processedPercent( float percent );
00193 
00199     void speed( unsigned long _bytes_per_second );
00200 
00205     void redirection( const KURL &_url );
00206 
00212     void errorPage();
00213 
00218     void mimeType( const QString &_type );
00219 
00223     void warning( const QString &msg );
00224 
00229     void infoMessage( const QString &msg );
00230 
00231     enum MessageBoxType { QuestionYesNo = 1, WarningYesNo = 2, WarningContinueCancel = 3, WarningYesNoCancel = 4, Information = 5, SSLMessageBox = 6 };
00232 
00246     int messageBox( MessageBoxType type, const QString &text,
00247                     const QString &caption = QString::null,
00248                     const QString &buttonYes = QString::null,
00249                     const QString &buttonNo = QString::null );
00250 
00267     int messageBox( const QString &text, MessageBoxType type,
00268                     const QString &caption = QString::null,
00269                     const QString &buttonYes = QString::null,
00270                     const QString &buttonNo = QString::null,
00271                     const QString &dontAskAgainName = QString::null );
00272 
00277     void setMetaData(const QString &key, const QString &value);
00278 
00284     bool hasMetaData(const QString &key) const;
00285 
00290     QString metaData(const QString &key) const;
00291 
00297     bool hasMetaData(const QString &key);
00298 
00303     QString metaData(const QString &key);
00304 
00312     KConfigBase* config();
00313 
00320     KRemoteEncoding* remoteEncoding();
00321     
00322 
00324     // Commands sent by the job, the slave has to
00325     // override what it wants to implement
00327 
00339     virtual void setHost(const QString& host, int port, const QString& user, const QString& pass);
00340 
00344     virtual void setSubURL(const KURL&url);
00345 
00355     virtual void openConnection();
00356 
00365     virtual void closeConnection();
00366 
00373     virtual void get( const KURL& url );
00374 
00384     virtual void put( const KURL& url, int permissions, bool overwrite, bool resume );
00385 
00391     virtual void stat( const KURL& url );
00392 
00405     virtual void mimetype( const KURL& url );
00406 
00414     virtual void listDir( const KURL& url );
00415 
00423     virtual void mkdir( const KURL&url, int permissions );
00424 
00433     virtual void rename( const KURL& src, const KURL& dest, bool overwrite );
00434 
00442     virtual void symlink( const QString& target, const KURL& dest, bool overwrite );
00443 
00448     virtual void chmod( const KURL& url, int permissions );
00449 
00460     virtual void copy( const KURL &src, const KURL &dest, int permissions, bool overwrite );
00461 
00468     virtual void del( const KURL &url, bool isfile);
00469 
00478     virtual void special( const QByteArray & data );
00479 
00487     virtual void multiGet( const QByteArray & data );
00488 
00493     virtual void slave_status();
00494 
00499     virtual void reparseConfiguration();
00500 
00501 
00505     int connectTimeout();
00506 
00510     int proxyConnectTimeout();
00511 
00516     int responseTimeout();
00517 
00522     int readTimeout();
00523 
00538     void setTimeoutSpecialCommand(int timeout, const QByteArray &data=QByteArray());
00539 
00543     static void sigsegv_handler(int);
00547     static void sigpipe_handler(int);
00548 
00550     // Dispatching (internal)
00552 
00556     virtual bool dispatch();
00560     virtual void dispatch( int command, const QByteArray &data );
00561 
00570     int readData( QByteArray &buffer );
00571 
00582     void listEntry( const UDSEntry& _entry, bool ready);
00583 
00588     void connectSlave(const QString& path);
00589     void disconnectSlave();
00590 
00635     bool openPassDlg( KIO::AuthInfo& info, const QString &errorMsg );
00636 
00641     bool openPassDlg( KIO::AuthInfo& info );
00642 
00670     bool checkCachedAuthentication( AuthInfo& info );
00671 
00678     bool cacheAuthentication( const AuthInfo& info );
00679 
00684     bool pingCacheDaemon() const;
00685 
00692     QString createAuthCacheKey( const KURL& url );
00693 
00701     void sendAuthenticationKey( const QCString& gKey, const QCString& key, bool keep );
00702 
00711     void delCachedAuthentication( const QString& key );
00712 
00717     void setMultipleAuthCaching( bool ) {};
00718 
00723     bool multipleAuthCaching() const { return false; }
00724 
00743     bool requestNetwork(const QString& host = QString::null);
00744 
00758     void dropNetwork(const QString& host = QString::null);
00759 
00764     DCOPClient *dcopClient();
00765 
00770     int waitForAnswer( int expected1, int expected2, QByteArray & data, int * pCmd = 0 );
00771 
00775     void sendMetaData();
00776 
00780     QCString mProtocol;
00781 
00782     Connection * m_pConnection;
00783 
00784     MetaData mOutgoingMetaData;
00785     MetaData mIncomingMetaData;
00786 
00793     bool wasKilled() const;
00794 
00799     void setKillFlag();
00800 
00801 protected:
00802     UDSEntryList pendingListEntries;
00803     uint listEntryCurrentSize;
00804     long listEntry_sec, listEntry_usec;
00805     Connection *appconn;
00806     QString mPoolSocket;
00807     QString mAppSocket;
00808     bool mConnectedToApp;
00809     static long s_seqNr;
00810     virtual void virtual_hook( int id, void* data );
00811 
00812 private:
00813     SlaveBasePrivate *d;
00814 };
00815 
00816 }
00817 
00818 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jan 22 16:47:18 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003