• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KIOSlave

ftp.h

Go to the documentation of this file.
00001 // -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*-
00002 /*  This file is part of the KDE libraries
00003     Copyright (C) 2000 David Faure <faure@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KDELIBS_FTP_H
00022 #define KDELIBS_FTP_H
00023 
00024 #include <config.h>
00025 
00026 #include <sys/types.h>
00027 #include <sys/socket.h>
00028 
00029 
00030 #include <QtCore/QByteRef>
00031 
00032 #include <QtNetwork/QTcpSocket>
00033 
00034 #include <kurl.h>
00035 #include <kio/slavebase.h>
00036 
00037 struct FtpEntry
00038 {
00039   QString name;
00040   QString owner;
00041   QString group;
00042   QString link;
00043 
00044   KIO::filesize_t size;
00045   mode_t type;
00046   mode_t access;
00047   time_t date;
00048 };
00049 
00050 //===============================================================================
00051 // Ftp
00052 //===============================================================================
00053 class Ftp : public KIO::SlaveBase
00054 {
00055   // Ftp()  {}
00056 
00057 public:
00058   Ftp( const QByteArray &pool, const QByteArray &app );
00059   virtual ~Ftp();
00060 
00061   virtual void setHost( const QString& host, quint16 port, const QString& user, const QString& pass );
00062 
00069   virtual void openConnection();
00070 
00074   virtual void closeConnection();
00075 
00076   virtual void stat( const KUrl &url );
00077 
00078   virtual void listDir( const KUrl & url );
00079   virtual void mkdir( const KUrl & url, int permissions );
00080   virtual void rename( const KUrl & src, const KUrl & dst, KIO::JobFlags flags );
00081   virtual void del( const KUrl & url, bool isfile );
00082   virtual void chmod( const KUrl & url, int permissions );
00083 
00084   virtual void get( const KUrl& url );
00085   virtual void put( const KUrl& url, int permissions, KIO::JobFlags flags );
00086   //virtual void mimetype( const KUrl& url );
00087 
00088   virtual void slave_status();
00089 
00093   virtual void copy( const KUrl &src, const KUrl &dest, int permissions, KIO::JobFlags flags );
00094 
00095 private:
00096   // ------------------------------------------------------------------------
00097   // All the methods named ftpXyz are lowlevel methods that are not exported.
00098   // The implement functionality used by the public high-level methods. Some
00099   // low-level methods still use error() to emit errors. This behaviour is not
00100   // recommended - please return a boolean status or an error code instead!
00101   // ------------------------------------------------------------------------
00102 
00107   typedef enum {
00108     statusSuccess,
00109     statusClientError,
00110     statusServerError
00111   } StatusCode;
00112 
00116   typedef enum {
00117     loginDefered,
00118     loginExplicit,
00119     loginImplicit
00120   } LoginMode;
00121 
00132   bool ftpOpenConnection (LoginMode loginMode);
00133 
00137   void ftpAutoLoginMacro ();
00138 
00146   bool ftpLogin();
00147 
00157   bool ftpSendCmd( const QByteArray& cmd, int maxretries = 1 );
00158 
00165   bool ftpSize( const QString & path, char mode );
00166 
00171   bool ftpFileExists(const QString& path);
00172 
00176   bool ftpFolder(const QString& path, bool bReportError);
00177 
00189   bool ftpOpenCommand( const char *command, const QString & path, char mode,
00190                        int errorcode, KIO::fileoffset_t offset = 0 );
00191 
00198   bool ftpCloseCommand();
00199 
00206   bool ftpDataMode(char cMode);
00207 
00208   //void ftpAbortTransfer();
00209 
00213   int ftpOpenDataConnection();
00214 
00218   void ftpCloseDataConnection();
00219 
00223   int ftpOpenPASVDataConnection();
00227   int ftpOpenEPSVDataConnection();
00231   int ftpOpenEPRTDataConnection();
00235   int ftpOpenPortDataConnection();
00236 
00243   int ftpAcceptConnect();
00244 
00245   bool ftpChmod( const QString & path, int permissions );
00246 
00247   // used by listDir
00248   bool ftpOpenDir( const QString & path );
00252   bool ftpReadDir(FtpEntry& ftpEnt);
00253 
00257   void ftpCreateUDSEntry( const QString & filename, FtpEntry& ftpEnt, KIO::UDSEntry& entry, bool isDir );
00258 
00259   void ftpShortStatAnswer( const QString& filename, bool isDir );
00260 
00261   void ftpStatAnswerNotFound( const QString & path, const QString & filename );
00262 
00268   bool ftpRename( const QString & src, const QString & dst, KIO::JobFlags flags );
00269 
00275   bool ftpOpenControlConnection( const QString & host, int port );
00276 
00280   void ftpCloseControlConnection();
00281 
00290   const char* ftpResponse(int iOffset);
00291 
00303   StatusCode ftpGet(int& iError, int iCopyFile, const KUrl& url, KIO::fileoffset_t hCopyOffset);
00304 
00315   StatusCode ftpPut(int& iError, int iCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
00316 
00325   StatusCode ftpCopyPut(int& iError, int& iCopyFile, const QString &sCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
00326 
00335   StatusCode ftpCopyGet(int& iError, int& iCopyFile, const QString &sCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
00336 
00337 private: // data members
00338 
00339   QString m_host;
00340   int m_port;
00341   QString m_user;
00342   QString m_pass;
00346   QString m_initialPath;
00347   KUrl m_proxyURL;
00348 
00352   QString m_currentPath;
00353 
00357   int  m_iRespCode;
00358 
00362   int  m_iRespType;
00363 
00368   char m_cDataMode;
00369 
00373   bool m_bLoggedOn;
00374 
00379   bool m_bTextMode;
00380 
00391   bool m_bBusy;
00392 
00393   bool m_bPasv;
00394   bool m_bUseProxy;
00395 
00396   KIO::filesize_t m_size;
00397   static KIO::filesize_t UnknownSize;
00398 
00399   enum
00400   {
00401     epsvUnknown = 0x01,
00402     epsvAllUnknown = 0x02,
00403     eprtUnknown = 0x04,
00404     epsvAllSent = 0x10,
00405     pasvUnknown = 0x20,
00406     chmodUnknown = 0x100
00407   };
00408   int m_extControl;
00409 
00413   QTcpSocket  *m_control;
00414   QByteArray m_lastControlLine;
00415 
00419   QTcpSocket  *m_data;
00420 };
00421 
00422 #endif // KDELIBS_FTP_H
00423 

KIOSlave

Skip menu "KIOSlave"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal