• Skip to content
  • Skip to link menu
KDE 4.3 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 #include <kurl.h>
00030 #include <kio/slavebase.h>
00031 class QTcpServer;
00032 class QTcpSocket;
00033 
00034 struct FtpEntry
00035 {
00036   QString name;
00037   QString owner;
00038   QString group;
00039   QString link;
00040 
00041   KIO::filesize_t size;
00042   mode_t type;
00043   mode_t access;
00044   time_t date;
00045 };
00046 
00047 //===============================================================================
00048 // Ftp
00049 //===============================================================================
00050 class Ftp : public KIO::SlaveBase
00051 {
00052   // Ftp()  {}
00053 
00054 public:
00055   Ftp( const QByteArray &pool, const QByteArray &app );
00056   virtual ~Ftp();
00057 
00058   virtual void setHost( const QString& host, quint16 port, const QString& user, const QString& pass );
00059 
00066   virtual void openConnection();
00067 
00071   virtual void closeConnection();
00072 
00073   virtual void stat( const KUrl &url );
00074 
00075   virtual void listDir( const KUrl & url );
00076   virtual void mkdir( const KUrl & url, int permissions );
00077   virtual void rename( const KUrl & src, const KUrl & dst, KIO::JobFlags flags );
00078   virtual void del( const KUrl & url, bool isfile );
00079   virtual void chmod( const KUrl & url, int permissions );
00080 
00081   virtual void get( const KUrl& url );
00082   virtual void put( const KUrl& url, int permissions, KIO::JobFlags flags );
00083   //virtual void mimetype( const KUrl& url );
00084 
00085   virtual void slave_status();
00086 
00090   virtual void copy( const KUrl &src, const KUrl &dest, int permissions, KIO::JobFlags flags );
00091 
00092 private:
00093   // ------------------------------------------------------------------------
00094   // All the methods named ftpXyz are lowlevel methods that are not exported.
00095   // The implement functionality used by the public high-level methods. Some
00096   // low-level methods still use error() to emit errors. This behaviour is not
00097   // recommended - please return a boolean status or an error code instead!
00098   // ------------------------------------------------------------------------
00099 
00104   typedef enum {
00105     statusSuccess,
00106     statusClientError,
00107     statusServerError
00108   } StatusCode;
00109 
00113   typedef enum {
00114     loginDefered,
00115     loginExplicit,
00116     loginImplicit
00117   } LoginMode;
00118 
00129   bool ftpOpenConnection (LoginMode loginMode);
00130 
00134   void ftpAutoLoginMacro ();
00135 
00143   bool ftpLogin();
00144 
00154   bool ftpSendCmd( const QByteArray& cmd, int maxretries = 1 );
00155 
00162   bool ftpSize( const QString & path, char mode );
00163 
00168   bool ftpFileExists(const QString& path);
00169 
00173   bool ftpFolder(const QString& path, bool bReportError);
00174 
00186   bool ftpOpenCommand( const char *command, const QString & path, char mode,
00187                        int errorcode, KIO::fileoffset_t offset = 0 );
00188 
00195   bool ftpCloseCommand();
00196 
00203   bool ftpDataMode(char cMode);
00204 
00205   //void ftpAbortTransfer();
00206 
00210   int ftpOpenDataConnection();
00211 
00215   void ftpCloseDataConnection();
00216 
00220   int ftpOpenPASVDataConnection();
00224   int ftpOpenEPSVDataConnection();
00228   int ftpOpenEPRTDataConnection();
00232   int ftpOpenPortDataConnection();
00233 
00240   int ftpAcceptConnect();
00241 
00242   bool ftpChmod( const QString & path, int permissions );
00243 
00244   // used by listDir
00245   bool ftpOpenDir( const QString & path );
00249   bool ftpReadDir(FtpEntry& ftpEnt);
00250 
00254   void ftpCreateUDSEntry( const QString & filename, FtpEntry& ftpEnt, KIO::UDSEntry& entry, bool isDir );
00255 
00256   void ftpShortStatAnswer( const QString& filename, bool isDir );
00257 
00258   void ftpStatAnswerNotFound( const QString & path, const QString & filename );
00259 
00265   bool ftpRename( const QString & src, const QString & dst, KIO::JobFlags flags );
00266 
00272   bool ftpOpenControlConnection( const QString & host, int port );
00273 
00277   void ftpCloseControlConnection();
00278 
00287   const char* ftpResponse(int iOffset);
00288 
00300   StatusCode ftpGet(int& iError, int iCopyFile, const KUrl& url, KIO::fileoffset_t hCopyOffset);
00301 
00312   StatusCode ftpPut(int& iError, int iCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
00313 
00322   StatusCode ftpCopyPut(int& iError, int& iCopyFile, const QString &sCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
00323 
00332   StatusCode ftpCopyGet(int& iError, int& iCopyFile, const QString &sCopyFile, const KUrl& url, int permissions, KIO::JobFlags flags);
00333 
00334 private: // data members
00335 
00336   QString m_host;
00337   int m_port;
00338   QString m_user;
00339   QString m_pass;
00343   QString m_initialPath;
00344   KUrl m_proxyURL;
00345 
00349   QString m_currentPath;
00350 
00354   int  m_iRespCode;
00355 
00359   int  m_iRespType;
00360 
00365   char m_cDataMode;
00366 
00370   bool m_bLoggedOn;
00371 
00376   bool m_bTextMode;
00377 
00388   bool m_bBusy;
00389 
00390   bool m_bPasv;
00391   bool m_bUseProxy;
00392 
00393   KIO::filesize_t m_size;
00394   static KIO::filesize_t UnknownSize;
00395 
00396   enum
00397   {
00398     epsvUnknown = 0x01,
00399     epsvAllUnknown = 0x02,
00400     eprtUnknown = 0x04,
00401     epsvAllSent = 0x10,
00402     pasvUnknown = 0x20,
00403     chmodUnknown = 0x100
00404   };
00405   int m_extControl;
00406 
00410   QTcpSocket  *m_control;
00411   QByteArray m_lastControlLine;
00412 
00416   QTcpSocket  *m_data;
00417 
00421   QTcpServer *m_server;
00422 };
00423 
00424 #endif // KDELIBS_FTP_H
00425 

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
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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